sqlserver支持alter table add default with values

This commit is contained in:
高铁
2020-10-23 14:09:06 +08:00
parent c35f09f9b7
commit 227d1f4f09
5 changed files with 109 additions and 1 deletions
@@ -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;
}