use of com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser 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.dialect.mysql.parser.MySqlStatementParser 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);
}
use of com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser in project druid by alibaba.
the class DMLUpdateParserTest method test_update_3.
public void test_update_3() throws Exception {
String sql = "upDate LOW_PRIORITY t1, test.t2 SET col2=DefaulT , col2='123''4'";
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'", output);
}
use of com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser in project druid by alibaba.
the class DMLUpdateParserTest method test_update_0.
public void test_update_0() throws Exception {
String sql = "upDate LOw_PRIORITY IGNORE test.t1 sEt t1.col1=?, col2=DefaulT";
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 IGNORE test.t1\nSET t1.col1 = ?, col2 = DEFAULT", output);
}
use of com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser in project druid by alibaba.
the class HintsTest method test_hints_none.
public void test_hints_none() throws Exception {
String sql = "SELECT /* STRAIGHT_JOIN */ col1 FROM table1,table2";
MySqlStatementParser parser = new MySqlStatementParser(sql);
SQLStatement stmt = parser.parseStatementList().get(0);
parser.match(Token.EOF);
String output = SQLUtils.toMySqlString(stmt);
Assert.assertEquals("SELECT col1\nFROM table1, table2", output);
}
Aggregations