mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
sqlserver支持alter table add default with values
This commit is contained in:
@@ -24,6 +24,7 @@ public class SQLDefault extends SQLConstraintImpl implements SQLTableElement, SQ
|
||||
|
||||
private SQLExpr expr;
|
||||
private SQLExpr column;
|
||||
private boolean withValues = false;
|
||||
|
||||
public SQLDefault(){
|
||||
|
||||
@@ -71,8 +72,14 @@ public class SQLDefault extends SQLConstraintImpl implements SQLTableElement, SQ
|
||||
super.cloneTo(x);
|
||||
|
||||
if (expr != null) {
|
||||
expr = expr.clone();
|
||||
x.setExpr(expr.clone());
|
||||
}
|
||||
|
||||
if (column != null) {
|
||||
x.setColumn(column.clone());
|
||||
}
|
||||
|
||||
x.setWithValues(x.isWithValues());
|
||||
}
|
||||
|
||||
public SQLDefault clone() {
|
||||
@@ -99,4 +106,12 @@ public class SQLDefault extends SQLConstraintImpl implements SQLTableElement, SQ
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isWithValues() {
|
||||
return withValues;
|
||||
}
|
||||
|
||||
public void setWithValues(boolean withValues) {
|
||||
this.withValues = withValues;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4814,6 +4814,12 @@ public class SQLExprParser extends SQLParser {
|
||||
accept(Token.FOR);
|
||||
sqlDefault.setColumn(this.expr());
|
||||
|
||||
if (lexer.token == Token.WITH) {
|
||||
lexer.nextToken();
|
||||
accept(Token.VALUES);
|
||||
sqlDefault.setWithValues(true);
|
||||
}
|
||||
|
||||
return sqlDefault;
|
||||
}
|
||||
|
||||
|
||||
@@ -1838,6 +1838,10 @@ public class SQLStatementParser extends SQLParser {
|
||||
|
||||
break;
|
||||
}
|
||||
} else if (lexer.token == DEFAULT) {
|
||||
SQLConstraint constraint = this.exprParser.parseConstaint();
|
||||
SQLAlterTableAddConstraint item = new SQLAlterTableAddConstraint(constraint);
|
||||
stmt.addItem(item);
|
||||
} else {
|
||||
throw new ParserException("TODO " + lexer.info());
|
||||
}
|
||||
|
||||
@@ -5290,6 +5290,11 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
||||
this.indentCount++;
|
||||
x.getColumn().accept(this);
|
||||
this.indentCount--;
|
||||
|
||||
if (x.isWithValues()) {
|
||||
print0(ucase ? " WITH VALUES" : " with values");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user