mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved db2 & oracle parser.
This commit is contained in:
@@ -203,6 +203,8 @@ public class DB2ExprParser extends SQLExprParser {
|
||||
|
||||
column.setGeneratedAlawsAs(expr);
|
||||
}
|
||||
|
||||
parseColumnRest(column);
|
||||
}
|
||||
|
||||
return column;
|
||||
@@ -212,33 +214,35 @@ public class DB2ExprParser extends SQLExprParser {
|
||||
SQLColumnDefinition.Identity identity = new SQLColumnDefinition.Identity();
|
||||
|
||||
accept(Token.IDENTITY);
|
||||
accept(Token.LPAREN);
|
||||
if (lexer.token() == Token.LPAREN) {
|
||||
accept(Token.LPAREN);
|
||||
|
||||
if (lexer.identifierEquals(FnvHash.Constants.START)) {
|
||||
lexer.nextToken();
|
||||
accept(Token.WITH);
|
||||
if (lexer.token() == Token.LITERAL_INT) {
|
||||
identity.setSeed((Integer) lexer.integerValue());
|
||||
if (lexer.identifierEquals(FnvHash.Constants.START)) {
|
||||
lexer.nextToken();
|
||||
} else {
|
||||
throw new ParserException("TODO " + lexer.info());
|
||||
accept(Token.WITH);
|
||||
if (lexer.token() == Token.LITERAL_INT) {
|
||||
identity.setSeed((Integer) lexer.integerValue());
|
||||
lexer.nextToken();
|
||||
} else {
|
||||
throw new ParserException("TODO " + lexer.info());
|
||||
}
|
||||
|
||||
accept(Token.COMMA);
|
||||
}
|
||||
|
||||
accept(Token.COMMA);
|
||||
}
|
||||
|
||||
if (lexer.identifierEquals(FnvHash.Constants.INCREMENT)) {
|
||||
lexer.nextToken();
|
||||
accept(Token.BY);
|
||||
if (lexer.token() == Token.LITERAL_INT) {
|
||||
identity.setIncrement((Integer) lexer.integerValue());
|
||||
if (lexer.identifierEquals(FnvHash.Constants.INCREMENT)) {
|
||||
lexer.nextToken();
|
||||
} else {
|
||||
throw new ParserException("TODO " + lexer.info());
|
||||
accept(Token.BY);
|
||||
if (lexer.token() == Token.LITERAL_INT) {
|
||||
identity.setIncrement((Integer) lexer.integerValue());
|
||||
lexer.nextToken();
|
||||
} else {
|
||||
throw new ParserException("TODO " + lexer.info());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
accept(Token.RPAREN);
|
||||
accept(Token.RPAREN);
|
||||
}
|
||||
|
||||
return identity;
|
||||
}
|
||||
|
||||
@@ -170,18 +170,28 @@ public class DB2OutputVisitor extends SQLASTOutputVisitor implements DB2ASTVisit
|
||||
}
|
||||
|
||||
public boolean visit(SQLColumnDefinition.Identity x) {
|
||||
print0(ucase ? "GENERATED ALWAYS AS IDENTITY (" : "generated always as identity (");
|
||||
print0(ucase ? "GENERATED ALWAYS AS IDENTITY" : "generated always as identity");
|
||||
|
||||
final Integer seed = x.getSeed();
|
||||
final Integer increment = x.getIncrement();
|
||||
|
||||
if (seed != null || increment != null) {
|
||||
print0(" (");
|
||||
}
|
||||
|
||||
if (seed != null) {
|
||||
print0(ucase ? "START WITH " : "start with ");
|
||||
print(seed);
|
||||
print0(", ");
|
||||
if (increment != null) {
|
||||
print0(", ");
|
||||
}
|
||||
}
|
||||
|
||||
print0(ucase ? "INCREMENT BY " : "increment by ");
|
||||
print(x.getIncrement());
|
||||
print(')');
|
||||
if (increment != null) {
|
||||
print0(ucase ? "INCREMENT BY " : "increment by ");
|
||||
print(increment);
|
||||
print(')');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user