use of com.alibaba.druid.sql.parser.SQLStatementParser in project druid by alibaba.
the class InsertSyntaxTest method test_3.
public void test_3() throws Exception {
String sql = "INSERT INTO tbl_name (a,b,c) VALUES(1,2,3),(4,5,6),(7,8,9);";
SQLStatementParser parser = new MySqlStatementParser(sql);
List<SQLStatement> stmtList = parser.parseStatementList();
String text = output(stmtList);
Assert.assertEquals(//
"INSERT INTO tbl_name (a, b, c)\nVALUES (1, 2, 3)," + //
"\n\t(4, 5, 6)," + "\n\t(7, 8, 9);", text);
}
use of com.alibaba.druid.sql.parser.SQLStatementParser in project druid by alibaba.
the class InsertSyntaxTest method test_2.
public void test_2() throws Exception {
String sql = "INSERT INTO tbl_name (col1,col2) VALUES(col2*2,15);";
SQLStatementParser parser = new MySqlStatementParser(sql);
List<SQLStatement> stmtList = parser.parseStatementList();
String text = output(stmtList);
Assert.assertEquals("INSERT INTO tbl_name (col1, col2)\nVALUES (col2 * 2, 15);", text);
}
use of com.alibaba.druid.sql.parser.SQLStatementParser in project druid by alibaba.
the class LoadDataInFileSyntaxTest method test_1.
public void test_1() throws Exception {
String sql = "LOAD DATA INFILE '/tmp/test.txt' INTO TABLE test FIELDS TERMINATED BY ',' LINES STARTING BY 'xxx';";
SQLStatementParser parser = new MySqlStatementParser(sql);
List<SQLStatement> stmtList = parser.parseStatementList();
String text = output(stmtList);
Assert.assertEquals("LOAD DATA INFILE '/tmp/test.txt' INTO TABLE test COLUMNS TERMINATED BY ',' LINES STARTING BY 'xxx';", text);
}
use of com.alibaba.druid.sql.parser.SQLStatementParser in project druid by alibaba.
the class EncryptionAndCompressionFunctionsTest method test_2.
public void test_2() throws Exception {
String sql = "SELECT LENGTH(COMPRESS(REPEAT('a',16)))";
SQLStatementParser parser = new MySqlStatementParser(sql);
List<SQLStatement> stmtList = parser.parseStatementList();
String text = output(stmtList);
Assert.assertEquals("SELECT LENGTH(COMPRESS(REPEAT('a', 16)));", text);
}
use of com.alibaba.druid.sql.parser.SQLStatementParser in project druid by alibaba.
the class FullTextSearchesWithQueryExpansionTest method test_0.
public void test_0() throws Exception {
String sql = "SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('database' IN NATURAL LANGUAGE MODE)";
SQLStatementParser parser = new MySqlStatementParser(sql);
List<SQLStatement> stmtList = parser.parseStatementList();
SQLStatement stmt = stmtList.get(0);
{
String text = SQLUtils.toMySqlString(stmt);
Assert.assertEquals(//
"SELECT *" + //
"\nFROM articles" + "\nWHERE MATCH (title, body) AGAINST ('database' IN NATURAL LANGUAGE MODE)", text);
}
{
String text = SQLUtils.toMySqlString(stmt, SQLUtils.DEFAULT_LCASE_FORMAT_OPTION);
Assert.assertEquals(//
"select *" + //
"\nfrom articles" + "\nwhere match (title, body) against ('database' in natural language mode)", text);
}
}
Aggregations