use of io.seata.sqlparser.SQLParsingException in project seata by seata.
the class MySQLUpdateRecognizer method getUpdateColumns.
@Override
public List<String> getUpdateColumns() {
List<SQLUpdateSetItem> updateSetItems = ast.getItems();
List<String> list = new ArrayList<>(updateSetItems.size());
for (SQLUpdateSetItem updateSetItem : updateSetItems) {
SQLExpr expr = updateSetItem.getColumn();
if (expr instanceof SQLIdentifierExpr) {
list.add(((SQLIdentifierExpr) expr).getName());
} else if (expr instanceof SQLPropertyExpr) {
// This is alias case, like UPDATE xxx_tbl a SET a.name = ? WHERE a.id = ?
SQLExpr owner = ((SQLPropertyExpr) expr).getOwner();
if (owner instanceof SQLIdentifierExpr) {
list.add(((SQLIdentifierExpr) owner).getName() + "." + ((SQLPropertyExpr) expr).getName());
// This is table Field Full path, like update xxx_database.xxx_tbl set xxx_database.xxx_tbl.xxx_field...
} else if (((SQLPropertyExpr) expr).getOwnernName().split("\\.").length > 1) {
list.add(((SQLPropertyExpr) expr).getOwnernName() + "." + ((SQLPropertyExpr) expr).getName());
}
} else {
throw new SQLParsingException("Unknown SQLExpr: " + expr.getClass() + " " + expr);
}
}
return list;
}
use of io.seata.sqlparser.SQLParsingException in project seata by seata.
the class OracleUpdateRecognizer method getUpdateColumns.
@Override
public List<String> getUpdateColumns() {
List<SQLUpdateSetItem> updateSetItems = ast.getItems();
List<String> list = new ArrayList<>(updateSetItems.size());
for (SQLUpdateSetItem updateSetItem : updateSetItems) {
SQLExpr expr = updateSetItem.getColumn();
if (expr instanceof SQLIdentifierExpr) {
list.add(((SQLIdentifierExpr) expr).getName());
} else if (expr instanceof SQLPropertyExpr) {
// This is alias case, like UPDATE xxx_tbl a SET a.name = ? WHERE a.id = ?
SQLExpr owner = ((SQLPropertyExpr) expr).getOwner();
if (owner instanceof SQLIdentifierExpr) {
list.add(((SQLIdentifierExpr) owner).getName() + "." + ((SQLPropertyExpr) expr).getName());
// This is table Field Full path, like update xxx_database.xxx_tbl set xxx_database.xxx_tbl.xxx_field...
} else if (((SQLPropertyExpr) expr).getOwnernName().split("\\.").length > 1) {
list.add(((SQLPropertyExpr) expr).getOwnernName() + "." + ((SQLPropertyExpr) expr).getName());
}
} else {
throw new SQLParsingException("Unknown SQLExpr: " + expr.getClass() + " " + expr);
}
}
return list;
}
use of io.seata.sqlparser.SQLParsingException in project seata by seata.
the class OracleUpdateRecognizer method getUpdateValues.
@Override
public List<Object> getUpdateValues() {
List<SQLUpdateSetItem> updateSetItems = ast.getItems();
List<Object> list = new ArrayList<>(updateSetItems.size());
for (SQLUpdateSetItem updateSetItem : updateSetItems) {
SQLExpr expr = updateSetItem.getValue();
if (expr instanceof SQLValuableExpr) {
list.add(((SQLValuableExpr) expr).getValue());
} else if (expr instanceof SQLVariantRefExpr) {
list.add(new VMarker());
} else {
throw new SQLParsingException("Unknown SQLExpr: " + expr.getClass() + " " + expr);
}
}
return list;
}
use of io.seata.sqlparser.SQLParsingException in project seata by seata.
the class PostgresqlUpdateRecognizer method getUpdateColumns.
@Override
public List<String> getUpdateColumns() {
List<SQLUpdateSetItem> updateSetItems = ast.getItems();
List<String> list = new ArrayList<>(updateSetItems.size());
for (SQLUpdateSetItem updateSetItem : updateSetItems) {
SQLExpr expr = updateSetItem.getColumn();
if (expr instanceof SQLIdentifierExpr) {
list.add(((SQLIdentifierExpr) expr).getName());
} else if (expr instanceof SQLPropertyExpr) {
// This is alias case, like UPDATE xxx_tbl a SET a.name = ? WHERE a.id = ?
SQLExpr owner = ((SQLPropertyExpr) expr).getOwner();
if (owner instanceof SQLIdentifierExpr) {
list.add(((SQLIdentifierExpr) owner).getName() + "." + ((SQLPropertyExpr) expr).getName());
// This is table Field Full path, like update xxx_database.xxx_tbl set xxx_database.xxx_tbl.xxx_field...
} else if (((SQLPropertyExpr) expr).getOwnernName().split("\\.").length > 1) {
list.add(((SQLPropertyExpr) expr).getOwnernName() + "." + ((SQLPropertyExpr) expr).getName());
}
} else {
throw new SQLParsingException("Unknown SQLExpr: " + expr.getClass() + " " + expr);
}
}
return list;
}
use of io.seata.sqlparser.SQLParsingException in project seata by seata.
the class MySQLInsertRecognizer method getInsertColumns.
@Override
public List<String> getInsertColumns() {
List<SQLExpr> columnSQLExprs = ast.getColumns();
if (columnSQLExprs.isEmpty()) {
// INSERT INTO ta VALUES (...), without fields clarified
return null;
}
List<String> list = new ArrayList<>(columnSQLExprs.size());
for (SQLExpr expr : columnSQLExprs) {
if (expr instanceof SQLIdentifierExpr) {
list.add(((SQLIdentifierExpr) expr).getName());
} else {
throw new SQLParsingException("Unknown SQLExpr: " + expr.getClass() + " " + expr);
}
}
return list;
}
Aggregations