mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
refactor
This commit is contained in:
+1
-1
@@ -59,7 +59,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
|
||||
accept(Token.TABLE);
|
||||
|
||||
if (identifierEquals("IF")) {
|
||||
if (lexer.token() == Token.IF || identifierEquals("IF")) {
|
||||
lexer.nextToken();
|
||||
accept(Token.NOT);
|
||||
accept(Token.EXISTS);
|
||||
|
||||
@@ -72,6 +72,15 @@ public class DDLParserTest extends TestCase {
|
||||
Assert.assertEquals("ALTER TABLE `test`.`tb1`" + //
|
||||
"\n\tDROP COLUMN `name`", output);
|
||||
}
|
||||
|
||||
public void test_createTable_0() throws Exception {
|
||||
String sql = "crEate temporary 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 TEMPORARY TABLE IF NOT EXISTS tb_name (\n\tfid int\n)", output);
|
||||
}
|
||||
|
||||
// public void testDDLStmt() throws Exception {
|
||||
// String sql = "alTer ignore table tb_name";
|
||||
|
||||
Reference in New Issue
Block a user