use of com.alibaba.druid.sql.ast.SQLStatement in project druid by alibaba.
the class DMLInsertParserTest method testInsert_1.
public void testInsert_1() throws Exception {
String sql = "insErt IGNORE test.t1 seT t1.id1:=? oN dupLicatE key UPDATE ex.col1=?, col2=12";
MySqlStatementParser parser = new MySqlStatementParser(sql);
SQLStatement stmt = parser.parseStatementList().get(0);
parser.match(Token.EOF);
String output = SQLUtils.toMySqlString(stmt);
Assert.assertEquals(//
"INSERT IGNORE INTO test.t1 (t1.id1)\nVALUES (?)" + "\nON DUPLICATE KEY UPDATE ex.col1 = ?, col2 = 12", output);
}
use of com.alibaba.druid.sql.ast.SQLStatement in project druid by alibaba.
the class DMLInsertParserTest method testInsert_3.
public void testInsert_3() throws Exception {
String sql = "insErt LOW_PRIORITY t1 valueS (12e-2,1,2), (?),(default)";
MySqlStatementParser parser = new MySqlStatementParser(sql);
SQLStatement stmt = parser.parseStatementList().get(0);
parser.match(Token.EOF);
String output = SQLUtils.toMySqlString(stmt);
Assert.assertEquals(//
"INSERT LOW_PRIORITY INTO t1\nVALUES (0.12, 1, 2)," + //
"\n\t(?)," + "\n\t(DEFAULT)", output);
}
use of com.alibaba.druid.sql.ast.SQLStatement in project druid by alibaba.
the class DDLParserTest method testAlterTable_3.
public void testAlterTable_3() throws Exception {
String sql = "ALTER TABLE `test`.`tb1` DROP COLUMN `name` ;";
MySqlStatementParser parser = new MySqlStatementParser(sql);
SQLStatement stmt = parser.parseStatementList().get(0);
parser.match(Token.EOF);
String output = SQLUtils.toMySqlString(stmt);
Assert.assertEquals(//
"ALTER TABLE `test`.`tb1`" + "\n\tDROP COLUMN `name`", output);
}
use of com.alibaba.druid.sql.ast.SQLStatement in project druid by alibaba.
the class DDLParserTest method test_createIndex_2.
public void test_createIndex_2() throws Exception {
String sql = "CREATE INDEX id_index ON lookup (id) USING BTREE;";
MySqlStatementParser parser = new MySqlStatementParser(sql);
SQLStatement stmt = parser.parseStatementList().get(0);
parser.match(Token.EOF);
String output = SQLUtils.toMySqlString(stmt);
Assert.assertEquals("CREATE INDEX id_index ON lookup (id) USING BTREE", output);
}
use of com.alibaba.druid.sql.ast.SQLStatement in project druid by alibaba.
the class DDLParserTest method testTruncate_1.
public void testTruncate_1() throws Exception {
String sql = "Truncate tb1";
MySqlStatementParser parser = new MySqlStatementParser(sql);
SQLStatement stmt = parser.parseStatementList().get(0);
parser.match(Token.EOF);
String output = SQLUtils.toMySqlString(stmt);
Assert.assertEquals("TRUNCATE TABLE tb1", output);
}
Aggregations