mysql parser ddl support

This commit is contained in:
温少
2012-05-16 16:51:03 +08:00
parent af75c60219
commit 953fa70373
13 changed files with 263 additions and 70 deletions
@@ -81,6 +81,24 @@ public class DDLParserTest extends TestCase {
String output = SQLUtils.toMySqlString(stmt);
Assert.assertEquals("CREATE TEMPORARY TABLE IF NOT EXISTS tb_name (\n\tfid int\n)", output);
}
public void test_createTable_1() throws Exception {
String sql = "crEate tabLe if not exists tb_name (fid int)";
MySqlStatementParser parser = new MySqlStatementParser(sql);
SQLStatement stmt = parser.parseStatementList().get(0);
parser.match(Token.EOF);
String output = SQLUtils.toMySqlString(stmt);
Assert.assertEquals("CREATE TABLE IF NOT EXISTS tb_name (\n\tfid int\n)", output);
}
public void test_createIndex_0() throws Exception {
String sql = "create index `idx1` ON tb1 (`fname` ASC) ;";
MySqlStatementParser parser = new MySqlStatementParser(sql);
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);
}
// public void testDDLStmt() throws Exception {
// String sql = "alTer ignore table tb_name";