Search in sources :

Example 1 with SQLSelectRecognizer

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

the class PostgresqlSelectForUpdateRecognizerTest method testGetTableName.

@Test
public void testGetTableName() {
    String sql = "select * from t where id = ? for update";
    SQLSelectRecognizer recognizer = (SQLSelectRecognizer) SQLVisitorFactory.get(sql, DB_TYPE).get(0);
    Assertions.assertEquals(recognizer.getTableName(), "t");
}
Also used : SQLSelectRecognizer(io.seata.sqlparser.SQLSelectRecognizer) Test(org.junit.jupiter.api.Test)

Example 2 with SQLSelectRecognizer

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

the class PostgresqlSelectForUpdateRecognizerTest method testGetTableAlias.

@Test
public void testGetTableAlias() {
    String sql = "select * from t where id = ? for update";
    SQLSelectRecognizer recognizer = (SQLSelectRecognizer) SQLVisitorFactory.get(sql, DB_TYPE).get(0);
    Assertions.assertNull(recognizer.getTableAlias());
}
Also used : SQLSelectRecognizer(io.seata.sqlparser.SQLSelectRecognizer) Test(org.junit.jupiter.api.Test)

Example 3 with SQLSelectRecognizer

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

the class PostgresqlSelectForUpdateRecognizerTest method testGetWhereCondition_1.

@Test
public void testGetWhereCondition_1() {
    String sql = "select * from t for update";
    SQLSelectRecognizer recognizer = (SQLSelectRecognizer) SQLVisitorFactory.get(sql, DB_TYPE).get(0);
    String whereCondition = recognizer.getWhereCondition();
    Assertions.assertEquals("", whereCondition);
}
Also used : SQLSelectRecognizer(io.seata.sqlparser.SQLSelectRecognizer) Test(org.junit.jupiter.api.Test)

Example 4 with SQLSelectRecognizer

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

the class PostgresqlSelectForUpdateRecognizerTest method testGetSqlType.

@Test
public void testGetSqlType() {
    String sql = "select * from t where id = ? for update";
    SQLSelectRecognizer recognizer = (SQLSelectRecognizer) SQLVisitorFactory.get(sql, DB_TYPE).get(0);
    Assertions.assertEquals(recognizer.getSQLType(), SQLType.SELECT_FOR_UPDATE);
}
Also used : SQLSelectRecognizer(io.seata.sqlparser.SQLSelectRecognizer) Test(org.junit.jupiter.api.Test)

Example 5 with SQLSelectRecognizer

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

the class PostgresqlSelectForUpdateRecognizerTest method testGetWhereCondition_0.

@Test
public void testGetWhereCondition_0() {
    String sql = "select * from t for update";
    SQLSelectRecognizer recognizer = (SQLSelectRecognizer) SQLVisitorFactory.get(sql, DB_TYPE).get(0);
    String whereCondition = recognizer.getWhereCondition(new ParametersHolder() {

        @Override
        public Map<Integer, ArrayList<Object>> getParameters() {
            return null;
        }
    }, new ArrayList<>());
    Assertions.assertEquals("", whereCondition);
}
Also used : ParametersHolder(io.seata.sqlparser.ParametersHolder) SQLSelectRecognizer(io.seata.sqlparser.SQLSelectRecognizer) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Aggregations

SQLSelectRecognizer (io.seata.sqlparser.SQLSelectRecognizer)6 Test (org.junit.jupiter.api.Test)5 ParametersHolder (io.seata.sqlparser.ParametersHolder)1 Map (java.util.Map)1