use of com.alibaba.druid.sql.ast.SQLStatement in project druid by alibaba.
the class DMLInsertParserTest method testInsert_8.
public void testInsert_8() throws Exception {
String sql = "insErt LOW_PRIORITY t1 (col1, t1.col2) select id from t3 oN dupLicatE key UPDATE ex.col1=?";
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 (col1, t1.col2)\nSELECT id\nFROM t3" + "\nON DUPLICATE KEY UPDATE ex.col1 = ?", output);
}
use of com.alibaba.druid.sql.ast.SQLStatement in project druid by alibaba.
the class DMLReplaceParserTest method testReplace_8.
public void testReplace_8() throws Exception {
String sql = "ReplaCe LOW_PRIORITY t1 (col1, t1.col2) VALUE (123,'123\\'4') ";
MySqlStatementParser parser = new MySqlStatementParser(sql);
SQLStatement stmt = parser.parseStatementList().get(0);
parser.match(Token.EOF);
String output = SQLUtils.toMySqlString(stmt);
Assert.assertEquals("REPLACE LOW_PRIORITY INTO t1 (col1, t1.col2)\nVALUES (123, '123''4')", output);
}
use of com.alibaba.druid.sql.ast.SQLStatement in project druid by alibaba.
the class DMLReplaceParserTest method testReplace_3.
public void testReplace_3() throws Exception {
String sql = "ReplaCe LOW_PRIORITY t1 valueS (12e-2), (?)";
MySqlStatementParser parser = new MySqlStatementParser(sql);
SQLStatement stmt = parser.parseStatementList().get(0);
parser.match(Token.EOF);
String output = SQLUtils.toMySqlString(stmt);
Assert.assertEquals("REPLACE LOW_PRIORITY INTO t1\nVALUES (0.12), (?)", output);
}
use of com.alibaba.druid.sql.ast.SQLStatement in project druid by alibaba.
the class DMLReplaceParserTest method testReplace_7.
public void testReplace_7() throws Exception {
String sql = "ReplaCe LOW_PRIORITY t1 (t1.col1) valueS (123),('12''34')";
MySqlStatementParser parser = new MySqlStatementParser(sql);
SQLStatement stmt = parser.parseStatementList().get(0);
parser.match(Token.EOF);
String output = SQLUtils.toMySqlString(stmt);
Assert.assertEquals("REPLACE LOW_PRIORITY INTO t1 (t1.col1)\nVALUES (123), ('12''34')", output);
}
use of com.alibaba.druid.sql.ast.SQLStatement in project druid by alibaba.
the class DMLReplaceParserTest method testReplace_0.
public void testReplace_0() throws Exception {
String sql = "ReplaCe LOW_PRIORITY intO test.t1 seT t1.id1:=?, id2='123'";
MySqlStatementParser parser = new MySqlStatementParser(sql);
SQLStatement stmt = parser.parseStatementList().get(0);
parser.match(Token.EOF);
String output = SQLUtils.toMySqlString(stmt);
Assert.assertEquals("REPLACE LOW_PRIORITY INTO test.t1 (t1.id1, id2)\nVALUES (?, '123')", output);
}
Aggregations