use of com.alibaba.druid.sql.ast.SQLStatement in project druid by alibaba.
the class DMLSelectParserTest method test_select_5.
public void test_select_5() throws Exception {
String sql = "SELect sql_cache id1,id2 from tb1,tb2 where tb1.id1=tb2.id1 ";
MySqlStatementParser parser = new MySqlStatementParser(sql);
SQLStatement stmt = parser.parseStatementList().get(0);
parser.match(Token.EOF);
String output = SQLUtils.toMySqlString(stmt);
Assert.assertEquals("SELECT SQL_CACHE id1, id2\nFROM tb1, tb2\nWHERE tb1.id1 = tb2.id1", output);
}
use of com.alibaba.druid.sql.ast.SQLStatement in project druid by alibaba.
the class DMLSelectParserTest method test_select_14.
public void test_select_14() throws Exception {
String sql = "SELect t1.* from tb ";
MySqlStatementParser parser = new MySqlStatementParser(sql);
SQLStatement stmt = parser.parseStatementList().get(0);
parser.match(Token.EOF);
String output = SQLUtils.toMySqlString(stmt);
Assert.assertEquals("SELECT t1.*\nFROM tb", output);
}
use of com.alibaba.druid.sql.ast.SQLStatement in project druid by alibaba.
the class DMLSelectParserTest method test_select_8.
public void test_select_8() throws Exception {
String sql = "SELect sql_cache id1,id2 from tb1,tb2 where tb1.id1=tb2.id1 ";
MySqlStatementParser parser = new MySqlStatementParser(sql);
SQLStatement stmt = parser.parseStatementList().get(0);
parser.match(Token.EOF);
String output = SQLUtils.toMySqlString(stmt);
Assert.assertEquals("SELECT SQL_CACHE id1, id2\nFROM tb1, tb2\nWHERE tb1.id1 = tb2.id1", output);
}
use of com.alibaba.druid.sql.ast.SQLStatement in project druid by alibaba.
the class DMLUpdateParserTest method test_update_1.
public void test_update_1() throws Exception {
String sql = "upDate IGNORE (t1) set col2=DefaulT order bY t1.col2 ";
MySqlStatementParser parser = new MySqlStatementParser(sql);
SQLStatement stmt = parser.parseStatementList().get(0);
parser.match(Token.EOF);
String output = SQLUtils.toMySqlString(stmt);
Assert.assertEquals("UPDATE IGNORE t1\nSET col2 = DEFAULT\nORDER BY t1.col2", output);
}
use of com.alibaba.druid.sql.ast.SQLStatement in project druid by alibaba.
the class DMLUpdateParserTest method test_update_4.
public void test_update_4() throws Exception {
String sql = "upDate LOW_PRIORITY t1, test.t2 SET col2:=DefaulT , col2='123''4' where id='a'";
MySqlStatementParser parser = new MySqlStatementParser(sql);
SQLStatement stmt = parser.parseStatementList().get(0);
parser.match(Token.EOF);
String output = SQLUtils.toMySqlString(stmt);
Assert.assertEquals("UPDATE LOW_PRIORITY t1, test.t2\nSET col2 = DEFAULT, col2 = '123''4'\nWHERE id = 'a'", output);
}
Aggregations