mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved oracle ddl support
This commit is contained in:
@@ -34,6 +34,7 @@ import com.alibaba.druid.util.FnvHash;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class OracleExprParser extends SQLExprParser {
|
||||
|
||||
@@ -121,6 +122,7 @@ public class OracleExprParser extends SQLExprParser {
|
||||
|
||||
protected boolean isCharType(long hash) {
|
||||
return hash == FnvHash.Constants.CHAR
|
||||
|| hash == FnvHash.Constants.CHARACTER
|
||||
|| hash == FnvHash.Constants.NCHAR
|
||||
|| hash == FnvHash.Constants.VARCHAR
|
||||
|| hash == FnvHash.Constants.VARCHAR2
|
||||
@@ -221,8 +223,43 @@ public class OracleExprParser extends SQLExprParser {
|
||||
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
if ("national".equalsIgnoreCase(typeName)
|
||||
&& isCharType(lexer.hash_lower())) {
|
||||
typeName += ' ' + lexer.stringVal();
|
||||
lexer.nextToken();
|
||||
|
||||
if (lexer.identifierEquals("VARYING")) {
|
||||
typeName += ' ' + lexer.stringVal();
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
SQLCharacterDataType charType = new SQLCharacterDataType(typeName);
|
||||
|
||||
if (lexer.token() == Token.LPAREN) {
|
||||
lexer.nextToken();
|
||||
SQLExpr arg = this.expr();
|
||||
arg.setParent(charType);
|
||||
charType.addArgument(arg);
|
||||
accept(Token.RPAREN);
|
||||
}
|
||||
|
||||
charType = (SQLCharacterDataType) parseCharTypeRest(charType);
|
||||
|
||||
if (lexer.token() == Token.HINT) {
|
||||
List<SQLCommentHint> hints = this.parseHints();
|
||||
charType.setHints(hints);
|
||||
}
|
||||
|
||||
return charType;
|
||||
}
|
||||
|
||||
if (isCharType(typeName)) {
|
||||
if (lexer.identifierEquals("VARYING")) {
|
||||
typeName += ' ' + lexer.stringVal();
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
SQLCharacterDataType charType = new SQLCharacterDataType(typeName);
|
||||
|
||||
if (lexer.token() == Token.LPAREN) {
|
||||
@@ -261,7 +298,6 @@ public class OracleExprParser extends SQLExprParser {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SQLDataTypeImpl dataType = new SQLDataTypeImpl(typeName);
|
||||
dataType.setDbType(dbType);
|
||||
return parseDataTypeRest(dataType);
|
||||
|
||||
Reference in New Issue
Block a user