mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved sql parser.
This commit is contained in:
@@ -27,9 +27,9 @@ public class SQLCommentStatement extends SQLStatementImpl {
|
||||
TABLE, COLUMN
|
||||
}
|
||||
|
||||
private SQLName on;
|
||||
private Type type;
|
||||
private SQLExpr comment;
|
||||
private SQLExprTableSource on;
|
||||
private Type type;
|
||||
private SQLExpr comment;
|
||||
|
||||
public SQLExpr getComment() {
|
||||
return comment;
|
||||
@@ -47,14 +47,21 @@ public class SQLCommentStatement extends SQLStatementImpl {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public SQLName getOn() {
|
||||
public SQLExprTableSource getOn() {
|
||||
return on;
|
||||
}
|
||||
|
||||
public void setOn(SQLName on) {
|
||||
public void setOn(SQLExprTableSource on) {
|
||||
if (on != null) {
|
||||
on.setParent(this);
|
||||
}
|
||||
this.on = on;
|
||||
}
|
||||
|
||||
public void setOn(SQLName on) {
|
||||
this.setOn(new SQLExprTableSource(on));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
if (visitor.visit(this)) {
|
||||
|
||||
@@ -624,7 +624,7 @@ public class SQLCreateTableStatement extends SQLStatementImpl implements SQLDDLS
|
||||
}
|
||||
|
||||
public boolean apply(SQLCommentStatement x) {
|
||||
SQLName on = x.getOn();
|
||||
SQLName on = x.getOn().getName();
|
||||
SQLExpr comment = x.getComment();
|
||||
if (comment == null) {
|
||||
return false;
|
||||
|
||||
@@ -3580,20 +3580,20 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
public boolean visit(SQLCommentStatement x) {
|
||||
SQLCommentStatement.Type type = x.getType();
|
||||
|
||||
SQLExpr on = x.getOn();
|
||||
SQLExprTableSource on = x.getOn();
|
||||
if (type == SQLCommentStatement.Type.TABLE) {
|
||||
print0(ucase ? "ALTER TABLE " : "alter table ");
|
||||
on.accept(this);
|
||||
print0(ucase ? " COMMENT = " : " comment = ");
|
||||
x.getComment().accept(this);
|
||||
} else {
|
||||
SQLPropertyExpr propertyExpr = (SQLPropertyExpr) on;
|
||||
SQLPropertyExpr propertyExpr = (SQLPropertyExpr) on.getExpr();
|
||||
|
||||
SQLExpr table = propertyExpr.getOwner();
|
||||
String column = propertyExpr.getName();
|
||||
|
||||
print0(ucase ? "ALTER TABLE " : "alter table ");
|
||||
table.accept(this);
|
||||
printTableSourceExpr(table);
|
||||
print0(ucase ? " MODIFY COLUMN " : " modify column ");
|
||||
print(column);
|
||||
print0(ucase ? " COMMENT " : " comment ");
|
||||
|
||||
Reference in New Issue
Block a user