mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
bug fixed for sql parser
This commit is contained in:
@@ -17,6 +17,7 @@ package com.alibaba.druid.sql.parser;
|
||||
|
||||
import com.alibaba.druid.sql.ast.statement.SQLColumnDefinition;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLCreateTableStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLPrimaryKey;
|
||||
|
||||
public class SQLCreateTableParser extends SQLDDLParser {
|
||||
|
||||
@@ -65,17 +66,23 @@ public class SQLCreateTableParser extends SQLDDLParser {
|
||||
if (lexer.token() == Token.LPAREN) {
|
||||
lexer.nextToken();
|
||||
|
||||
while (lexer.token() == Token.IDENTIFIER || lexer.token() == Token.LITERAL_ALIAS) {
|
||||
SQLColumnDefinition column = this.exprParser.parseColumn();
|
||||
createTable.getTableElementList().add(column);
|
||||
|
||||
// parseConstaint(column.getConstaints());
|
||||
|
||||
if (lexer.token() != Token.COMMA) {
|
||||
break;
|
||||
for (;;) {
|
||||
if (lexer.token() == Token.IDENTIFIER || lexer.token() == Token.LITERAL_ALIAS) {
|
||||
SQLColumnDefinition column = this.exprParser.parseColumn();
|
||||
createTable.getTableElementList().add(column);
|
||||
} else if (lexer.token() == Token.PRIMARY) {
|
||||
SQLPrimaryKey primaryKey = exprParser.parsePrimaryKey();
|
||||
createTable.getTableElementList().add(primaryKey);
|
||||
} else {
|
||||
throw new ParserException("TODO " + lexer.token());
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.COMMA) {
|
||||
lexer.nextToken();
|
||||
continue;
|
||||
}
|
||||
|
||||
lexer.nextToken();
|
||||
break;
|
||||
}
|
||||
|
||||
// while
|
||||
@@ -91,10 +98,6 @@ public class SQLCreateTableParser extends SQLDDLParser {
|
||||
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.ON) {
|
||||
throw new ParserException("TODO");
|
||||
}
|
||||
|
||||
return createTable;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user