mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved sql parser.
This commit is contained in:
@@ -37,25 +37,20 @@ public class SQLServerSelectTest6 extends TestCase {
|
||||
"FROM DirReps " + //
|
||||
"ORDER BY ManagerID;";
|
||||
|
||||
String expect = "WITH" +
|
||||
"\n\tDirReps (ManagerID, DirectReports)" +
|
||||
"\n\tAS" +
|
||||
"\n\t(" +
|
||||
"\n\t\tSELECT ManagerID, COUNT(*)" +
|
||||
"\n\t\tFROM HumanResources.Employee e" +
|
||||
"\n\t\tWHERE ManagerID IS NOT NULL" +
|
||||
"\n\t\tGROUP BY ManagerID" +
|
||||
"\n\t)" +
|
||||
"\nSELECT ManagerID, DirectReports" +
|
||||
"\nFROM DirReps" +
|
||||
"\nORDER BY ManagerID;";
|
||||
|
||||
SQLServerStatementParser parser = new SQLServerStatementParser(sql);
|
||||
SQLStatement stmt = parser.parseStatementList().get(0);
|
||||
|
||||
String text = TestUtils.outputSqlServer(stmt);
|
||||
|
||||
Assert.assertEquals(expect, text);
|
||||
assertEquals("WITH DirReps (ManagerID, DirectReports) AS (\n" +
|
||||
"\t\tSELECT ManagerID, COUNT(*)\n" +
|
||||
"\t\tFROM HumanResources.Employee e\n" +
|
||||
"\t\tWHERE ManagerID IS NOT NULL\n" +
|
||||
"\t\tGROUP BY ManagerID\n" +
|
||||
"\t)\n" +
|
||||
"SELECT ManagerID, DirectReports\n" +
|
||||
"FROM DirReps\n" +
|
||||
"ORDER BY ManagerID;", text);
|
||||
|
||||
// System.out.println(text);
|
||||
}
|
||||
|
||||
@@ -68,10 +68,7 @@ public class SQLServerSelectTest7 extends TestCase {
|
||||
|
||||
String text = TestUtils.outputSqlServer(stmt);
|
||||
|
||||
assertEquals("WITH\n" +
|
||||
"\tmenu_view\n" +
|
||||
"\tAS\n" +
|
||||
"\t(\n" +
|
||||
assertEquals("WITH menu_view AS (\n" +
|
||||
"\t\tSELECT t.*, 1 AS level\n" +
|
||||
"\t\tFROM sec_portal_menu t\n" +
|
||||
"\t\tWHERE t.parent_id = ?\n" +
|
||||
|
||||
Reference in New Issue
Block a user