use of com.alibaba.druid.sql.ast.SQLStatement in project druid by alibaba.
the class DDLParserTest method test_createIndex_4.
public void test_createIndex_4() throws Exception {
String sql = "crEate spatial index index_name on tb(col(id))";
MySqlStatementParser parser = new MySqlStatementParser(sql);
SQLStatement stmt = parser.parseStatementList().get(0);
parser.match(Token.EOF);
String output = SQLUtils.toMySqlString(stmt);
Assert.assertEquals("CREATE SPATIAL INDEX index_name ON tb (col(id))", output);
}
use of com.alibaba.druid.sql.ast.SQLStatement in project druid by alibaba.
the class DDLParserTest method test_rename_0.
public void test_rename_0() throws Exception {
String sql = "RENAME TABLE current_db.tbl_name TO other_db.tbl_name";
MySqlStatementParser parser = new MySqlStatementParser(sql);
SQLStatement stmt = parser.parseStatementList().get(0);
parser.match(Token.EOF);
String output = SQLUtils.toMySqlString(stmt);
Assert.assertEquals("RENAME TABLE current_db.tbl_name TO other_db.tbl_name", output);
}
use of com.alibaba.druid.sql.ast.SQLStatement in project druid by alibaba.
the class DMLSelectParserTest method test_select_7.
public void test_select_7() throws Exception {
String sql = "SELect distinctrow high_priority sql_small_result tb1.id,tb2.id " + "from tb1,tb2 where tb1.id2=tb2.id2";
MySqlStatementParser parser = new MySqlStatementParser(sql);
SQLStatement stmt = parser.parseStatementList().get(0);
parser.match(Token.EOF);
String output = SQLUtils.toMySqlString(stmt);
Assert.assertEquals("SELECT DISTINCTROW HIGH_PRIORITY SQL_SMALL_RESULT tb1.id, tb2.id\nFROM tb1, tb2\nWHERE tb1.id2 = tb2.id2", output);
}
use of com.alibaba.druid.sql.ast.SQLStatement in project druid by alibaba.
the class DMLSelectParserTest method test_union_2.
public void test_union_2() throws Exception {
String sql = "(select id from t1) union distInct (select id from t2) union select id from t3";
MySqlStatementParser parser = new MySqlStatementParser(sql);
SQLStatement stmt = parser.parseStatementList().get(0);
parser.match(Token.EOF);
String output = SQLUtils.toMySqlString(stmt);
Assert.assertEquals("SELECT id\nFROM t1\nUNION DISTINCT\nSELECT id\nFROM t2\nUNION\nSELECT id\nFROM t3", output);
}
use of com.alibaba.druid.sql.ast.SQLStatement in project druid by alibaba.
the class DMLSelectParserTest method test_select_11.
public void test_select_11() throws Exception {
String sql = "SELect SQL_no_cache tb1.id1,id2 from tb1";
MySqlStatementParser parser = new MySqlStatementParser(sql);
SQLStatement stmt = parser.parseStatementList().get(0);
parser.match(Token.EOF);
String output = SQLUtils.toMySqlString(stmt);
Assert.assertEquals("SELECT SQL_NO_CACHE tb1.id1, id2\nFROM tb1", output);
}
Aggregations