refactor sql parser.

This commit is contained in:
wenshao
2017-06-10 07:40:05 +08:00
parent 7c4a43d2c5
commit 5434b65260
310 changed files with 1067 additions and 1091 deletions
@@ -645,7 +645,7 @@ public class DALParserTest extends TestCase {
MySqlShowGrantsStatement show = (MySqlShowGrantsStatement) parser.parseStatementList().get(0);
parser.match(Token.EOF);
String output = SQLUtils.toMySqlString(show);
Assert.assertEquals("SHOW GRANTS FOR 'root'@'localhost'", output);
assertEquals("SHOW GRANTS FOR 'root'@'localhost';", output);
}
public void test_show_grants_1() throws Exception {
@@ -953,7 +953,7 @@ public class DALParserTest extends TestCase {
MySqlShowVariantsStatement show = (MySqlShowVariantsStatement) parser.parseStatementList().get(0);
parser.match(Token.EOF);
String output = SQLUtils.toMySqlString(show);
Assert.assertEquals("SHOW VARIABLES LIKE '%size%'", output);
assertEquals("SHOW VARIABLES LIKE '%size%';", output);
}
public void test_show_variants_1() throws Exception {
@@ -962,7 +962,7 @@ public class DALParserTest extends TestCase {
MySqlShowVariantsStatement show = (MySqlShowVariantsStatement) parser.parseStatementList().get(0);
parser.match(Token.EOF);
String output = SQLUtils.toMySqlString(show);
Assert.assertEquals("SHOW GLOBAL VARIABLES LIKE '%size%'", output);
assertEquals("SHOW GLOBAL VARIABLES LIKE '%size%';", output);
}
public void test_show_variants_2() throws Exception {
@@ -971,7 +971,7 @@ public class DALParserTest extends TestCase {
MySqlShowVariantsStatement show = (MySqlShowVariantsStatement) parser.parseStatementList().get(0);
parser.match(Token.EOF);
String output = SQLUtils.toMySqlString(show);
Assert.assertEquals("SHOW SESSION VARIABLES LIKE '%size%'", output);
assertEquals("SHOW SESSION VARIABLES LIKE '%size%';", output);
}
//
@@ -75,7 +75,7 @@ public class DDLParserTest extends TestCase {
parser.match(Token.EOF);
String output = SQLUtils.toMySqlString(stmt);
Assert.assertEquals("ALTER TABLE `test`.`tb1`" + //
"\n\tADD COLUMN `name` VARCHAR(45) NULL AFTER `fid`", output);
"\n\tADD COLUMN `name` VARCHAR(45) NULL AFTER `fid`;", output);
}
public void testAlterTable_3() throws Exception {
@@ -85,7 +85,7 @@ public class DDLParserTest extends TestCase {
parser.match(Token.EOF);
String output = SQLUtils.toMySqlString(stmt);
Assert.assertEquals("ALTER TABLE `test`.`tb1`" + //
"\n\tDROP COLUMN `name`", output);
"\n\tDROP COLUMN `name`;", output);
}
public void test_createTable_0() throws Exception {
@@ -114,7 +114,7 @@ public class DDLParserTest extends TestCase {
SQLStatement stmt = parser.parseStatementList().get(0);
parser.match(Token.EOF);
String output = SQLUtils.toMySqlString(stmt);
Assert.assertEquals("CREATE INDEX `idx1` ON tb1 (`fname` ASC)", output);
Assert.assertEquals("CREATE INDEX `idx1` ON tb1 (`fname` ASC);", output);
}
public void test_createIndex_1() throws Exception {
@@ -123,7 +123,7 @@ public class DDLParserTest extends TestCase {
SQLStatement stmt = parser.parseStatementList().get(0);
parser.match(Token.EOF);
String output = SQLUtils.toMySqlString(stmt);
Assert.assertEquals("CREATE UNIQUE INDEX `idx1` ON tb1 (`fname` DESC)", output);
Assert.assertEquals("CREATE UNIQUE INDEX `idx1` ON tb1 (`fname` DESC);", output);
}
public void test_createIndex_2() throws Exception {
@@ -132,7 +132,7 @@ public class DDLParserTest extends TestCase {
SQLStatement stmt = parser.parseStatementList().get(0);
parser.match(Token.EOF);
String output = SQLUtils.toMySqlString(stmt);
Assert.assertEquals("CREATE INDEX id_index ON lookup (id) USING BTREE", output);
Assert.assertEquals("CREATE INDEX id_index ON lookup (id) USING BTREE;", output);
}
public void test_createIndex_3() throws Exception {
@@ -168,7 +168,7 @@ public class DDLParserTest extends TestCase {
SQLStatement stmt = parser.parseStatementList().get(0);
parser.match(Token.EOF);
String output = SQLUtils.toMySqlString(stmt);
Assert.assertEquals("DROP INDEX `PRIMARY` ON t", output);
Assert.assertEquals("DROP INDEX `PRIMARY` ON t;", output);
}
public void test_drop_table_0() throws Exception {
@@ -32,7 +32,7 @@ public class HintsTest extends TestCase {
SQLStatement stmt = parser.parseStatementList().get(0);
parser.match(Token.EOF);
String output = SQLUtils.toMySqlString(stmt);
Assert.assertEquals("CREATE /*!32302 TEMPORARY */ TABLE t (\n\ta INT\n)", output);
Assert.assertEquals("CREATE /*!32302 TEMPORARY */ TABLE t (\n\ta INT\n);", output);
}
public void test_hints_1() throws Exception {
@@ -94,7 +94,7 @@ public class MTSParserTest extends TestCase {
SQLStatement stmt = parser.parseStatementList().get(0);
parser.match(Token.EOF);
String output = SQLUtils.toMySqlString(stmt);
Assert.assertEquals("LOCK TABLES t1 READ", output);
Assert.assertEquals("LOCK TABLES t1 READ;", output);
}
public void test_lockTable_1() throws Exception {
@@ -103,7 +103,7 @@ public class MTSParserTest extends TestCase {
SQLStatement stmt = parser.parseStatementList().get(0);
parser.match(Token.EOF);
String output = SQLUtils.toMySqlString(stmt);
Assert.assertEquals("LOCK TABLES t2 READ LOCAL", output);
Assert.assertEquals("LOCK TABLES t2 READ LOCAL;", output);
}
public void test_unlockTable() throws Exception {