mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
支持mysql create/alter列中包含charset的解析
This commit is contained in:
@@ -53,8 +53,9 @@ public class MySqlCharExpr extends SQLCharExpr implements MySqlExpr {
|
||||
buf.append(charset);
|
||||
buf.append(' ');
|
||||
}
|
||||
|
||||
super.output(buf);
|
||||
if (super.text!=null){
|
||||
super.output(buf);
|
||||
}
|
||||
|
||||
if (collate != null) {
|
||||
buf.append(" COLLATE ");
|
||||
|
||||
+11
@@ -26,10 +26,21 @@ public class MySqlSQLColumnDefinition extends SQLColumnDefinition {
|
||||
|
||||
private SQLExpr storage;
|
||||
|
||||
private SQLExpr charsetExpr;
|
||||
|
||||
|
||||
public MySqlSQLColumnDefinition(){
|
||||
|
||||
}
|
||||
|
||||
public SQLExpr getCharsetExpr() {
|
||||
return charsetExpr;
|
||||
}
|
||||
|
||||
public void setCharsetExpr(SQLExpr charsetExpr) {
|
||||
this.charsetExpr = charsetExpr;
|
||||
}
|
||||
|
||||
public boolean isAutoIncrement() {
|
||||
return autoIncrement;
|
||||
}
|
||||
|
||||
@@ -531,7 +531,19 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
SQLExpr expr = this.expr();
|
||||
((MySqlSQLColumnDefinition) column).setOnUpdate(expr);
|
||||
}
|
||||
|
||||
if (identifierEquals("CHARSET")) {
|
||||
lexer.nextToken();
|
||||
MySqlCharExpr charSetCollateExpr=new MySqlCharExpr();
|
||||
charSetCollateExpr.setCharset(lexer.stringVal());
|
||||
lexer.nextToken();
|
||||
if (identifierEquals("COLLATE")) {
|
||||
lexer.nextToken();
|
||||
charSetCollateExpr.setCollate(lexer.stringVal());
|
||||
lexer.nextToken();
|
||||
}
|
||||
((MySqlSQLColumnDefinition) column).setCharsetExpr(charSetCollateExpr);
|
||||
return parseColumnRest(column);
|
||||
}
|
||||
if (identifierEquals("AUTO_INCREMENT")) {
|
||||
lexer.nextToken();
|
||||
if (column instanceof MySqlSQLColumnDefinition) {
|
||||
|
||||
@@ -309,6 +309,11 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
print(' ');
|
||||
x.getDataType().accept(this);
|
||||
|
||||
if (mysqlColumn != null && mysqlColumn.getCharsetExpr() != null) {
|
||||
print(" CHARSET ");
|
||||
mysqlColumn.getCharsetExpr().accept(this);
|
||||
}
|
||||
|
||||
for (SQLColumnConstraint item : x.getConstraints()) {
|
||||
print(' ');
|
||||
item.accept(this);
|
||||
|
||||
Reference in New Issue
Block a user