use of com.alibaba.druid.sql.parser.SQLStatementParser in project druid by alibaba.
the class DateAndTimeFunctionsTest method test_45.
public void test_45() throws Exception {
String sql = "SELECT TIMESTAMPDIFF(MONTH,'2003-02-01','2003-05-01');";
SQLStatementParser parser = new MySqlStatementParser(sql);
List<SQLStatement> stmtList = parser.parseStatementList();
String text = output(stmtList);
Assert.assertEquals("SELECT TIMESTAMPDIFF(MONTH, '2003-02-01', '2003-05-01');", text);
}
use of com.alibaba.druid.sql.parser.SQLStatementParser in project druid by alibaba.
the class DateAndTimeValuesTest method test_2.
public void test_2() throws Exception {
String sql = "SELECT '2008-02-31' + INTERVAL 0 MONTH";
SQLStatementParser parser = new MySqlStatementParser(sql);
List<SQLStatement> stmtList = parser.parseStatementList();
String text = output(stmtList);
Assert.assertEquals("SELECT '2008-02-31' + INTERVAL 0 MONTH;", text);
}
use of com.alibaba.druid.sql.parser.SQLStatementParser in project druid by alibaba.
the class DeleteSyntaxTest method test_3.
public void test_3() throws Exception {
String sql = "DELETE FROM a1, a2 USING t1 AS a1 INNER JOIN t2 AS a2 WHERE a1.id=a2.id";
SQLStatementParser parser = new MySqlStatementParser(sql);
List<SQLStatement> stmtList = parser.parseStatementList();
SQLStatement stmt = stmtList.get(0);
Assert.assertEquals(//
"DELETE FROM a1, a2 USING (t1) AS a1" + "\n\tINNER JOIN t2 a2\nWHERE a1.id = a2.id", SQLUtils.toMySqlString(stmt));
Assert.assertEquals(//
"delete from a1, a2 using (t1) as a1" + "\n\tinner join t2 a2\nwhere a1.id = a2.id", SQLUtils.toMySqlString(stmt, SQLUtils.DEFAULT_LCASE_FORMAT_OPTION));
}
use of com.alibaba.druid.sql.parser.SQLStatementParser in project druid by alibaba.
the class DeleteSyntaxTest method test_4.
public void test_4() throws Exception {
String sql = "DELETE LOW_PRIORITY QUICK IGNORE FROM T";
SQLStatementParser parser = new MySqlStatementParser(sql);
List<SQLStatement> stmtList = parser.parseStatementList();
SQLStatement stmt = stmtList.get(0);
Assert.assertEquals("DELETE LOW_PRIORITY QUICK IGNORE FROM T", SQLUtils.toMySqlString(stmt));
Assert.assertEquals("delete low_priority quick ignore from T", SQLUtils.toMySqlString(stmt, SQLUtils.DEFAULT_LCASE_FORMAT_OPTION));
}
use of com.alibaba.druid.sql.parser.SQLStatementParser in project druid by alibaba.
the class DeleteSyntaxTest method test_1.
public void test_1() throws Exception {
String sql = "DELETE t1 FROM t1 LEFT JOIN t2 ON t1.id=t2.id WHERE t2.id IS NULL;";
SQLStatementParser parser = new MySqlStatementParser(sql);
List<SQLStatement> stmtList = parser.parseStatementList();
SQLStatement stmt = stmtList.get(0);
Assert.assertEquals(//
"DELETE t1" + //
"\nFROM t1" + //
"\n\tLEFT JOIN t2 ON t1.id = t2.id" + "\nWHERE t2.id IS NULL", SQLUtils.toMySqlString(stmt));
}
Aggregations