use of com.alibaba.druid.sql.parser.SQLStatementParser in project druid by alibaba.
the class DateAndTimeFunctionsTest method test_0.
public void test_0() throws Exception {
String sql = "SELECT something FROM tbl_name WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY) <= date_col";
SQLStatementParser parser = new MySqlStatementParser(sql);
List<SQLStatement> stmtList = parser.parseStatementList();
String text = output(stmtList);
Assert.assertEquals("SELECT something\nFROM tbl_name\nWHERE DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date_col;", text);
}
use of com.alibaba.druid.sql.parser.SQLStatementParser in project druid by alibaba.
the class CastFunctionsAndOperatorsTest method test_2.
public void test_2() throws Exception {
String sql = "SELECT CONVERT('abc' USING utf8)";
SQLStatementParser parser = new MySqlStatementParser(sql);
List<SQLStatement> stmtList = parser.parseStatementList();
String text = output(stmtList);
Assert.assertEquals("SELECT CONVERT('abc' USING utf8);", text);
}
use of com.alibaba.druid.sql.parser.SQLStatementParser in project druid by alibaba.
the class CastFunctionsAndOperatorsTest method test_9.
public void test_9() throws Exception {
String sql = "SELECT CAST(1-2 AS UNSIGNED);";
SQLStatementParser parser = new MySqlStatementParser(sql);
List<SQLStatement> stmtList = parser.parseStatementList();
String text = output(stmtList);
Assert.assertEquals("SELECT CAST(1 - 2 AS UNSIGNED);", text);
}
use of com.alibaba.druid.sql.parser.SQLStatementParser in project druid by alibaba.
the class CastFunctionsAndOperatorsTest method test_4.
public void test_4() throws Exception {
String sql = "SELECT 'A' LIKE CONVERT(blob_col USING latin1) COLLATE latin1_german1_ci FROM tbl_name;";
SQLStatementParser parser = new MySqlStatementParser(sql);
List<SQLStatement> stmtList = parser.parseStatementList();
String text = output(stmtList);
Assert.assertEquals("SELECT 'A' LIKE CONVERT(blob_col USING latin1) COLLATE latin1_german1_ci\nFROM tbl_name;", text);
}
use of com.alibaba.druid.sql.parser.SQLStatementParser in project druid by alibaba.
the class ComparisonFunctionsAndOperatorsTest method test_13.
public void test_13() throws Exception {
String sql = "SELECT * FROM tbl_name WHERE date_column IS NULL";
SQLStatementParser parser = new MySqlStatementParser(sql);
List<SQLStatement> stmtList = parser.parseStatementList();
String text = output(stmtList);
Assert.assertEquals("SELECT *\nFROM tbl_name\nWHERE date_column IS NULL;", text);
}
Aggregations