Search in sources :

Example 6 with SQLDeleteRecognizer

use of io.seata.sqlparser.SQLDeleteRecognizer in project seata by seata.

the class PostgresqlDeleteRecognizerTest method testGetTableName.

@Test
public void testGetTableName() {
    String sql = "delete from t where id = ?";
    List<SQLStatement> asts = SQLUtils.parseStatements(sql, DB_TYPE);
    List<SQLRecognizer> sqlRecognizers = SQLVisitorFactory.get(sql, DB_TYPE);
    SQLDeleteRecognizer recognizer = (SQLDeleteRecognizer) sqlRecognizers.get(0);
    Assertions.assertEquals(recognizer.getTableName(), "t");
}
Also used : SQLRecognizer(io.seata.sqlparser.SQLRecognizer) SQLStatement(com.alibaba.druid.sql.ast.SQLStatement) SQLDeleteRecognizer(io.seata.sqlparser.SQLDeleteRecognizer) Test(org.junit.jupiter.api.Test)

Example 7 with SQLDeleteRecognizer

use of io.seata.sqlparser.SQLDeleteRecognizer in project seata by seata.

the class DeleteExecutor method beforeImage.

@Override
protected TableRecords beforeImage() throws SQLException {
    SQLDeleteRecognizer visitor = (SQLDeleteRecognizer) sqlRecognizer;
    TableMeta tmeta = getTableMeta(visitor.getTableName());
    ArrayList<List<Object>> paramAppenderList = new ArrayList<>();
    String selectSQL = buildBeforeImageSQL(visitor, tmeta, paramAppenderList);
    return buildTableRecords(tmeta, selectSQL, paramAppenderList);
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) TableMeta(io.seata.rm.datasource.sql.struct.TableMeta) SQLDeleteRecognizer(io.seata.sqlparser.SQLDeleteRecognizer)

Aggregations

SQLDeleteRecognizer (io.seata.sqlparser.SQLDeleteRecognizer)7 SQLRecognizer (io.seata.sqlparser.SQLRecognizer)6 Test (org.junit.jupiter.api.Test)5 TableMeta (io.seata.rm.datasource.sql.struct.TableMeta)2 ParametersHolder (io.seata.sqlparser.ParametersHolder)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 SQLStatement (com.alibaba.druid.sql.ast.SQLStatement)1 NotSupportYetException (io.seata.common.exception.NotSupportYetException)1 Map (java.util.Map)1 StringJoiner (java.util.StringJoiner)1