mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 1999-2101 Alibaba Group Holding Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.druid.sql.ast.statement;
|
||||
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
public class NullConstraint extends SQLConstraintImpl implements SQLColumnConstraint {
|
||||
|
||||
public NullConstraint(){
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
visitor.visit(this);
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
}
|
||||
@@ -65,6 +65,7 @@ import com.alibaba.druid.sql.ast.expr.SQLUnaryExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLUnaryOperator;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLVariantRefExpr;
|
||||
import com.alibaba.druid.sql.ast.statement.NotNullConstraint;
|
||||
import com.alibaba.druid.sql.ast.statement.NullConstraint;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLAssignItem;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLCharacterDataType;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLCheck;
|
||||
@@ -1688,7 +1689,7 @@ public class SQLExprParser extends SQLParser {
|
||||
|
||||
if (lexer.token() == Token.NULL) {
|
||||
lexer.nextToken();
|
||||
column.setDefaultExpr(new SQLNullExpr());
|
||||
column.getConstraints().add(new NullConstraint());
|
||||
return parseColumnRest(column);
|
||||
}
|
||||
|
||||
|
||||
@@ -1192,6 +1192,16 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Printab
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean visit(NullConstraint x) {
|
||||
if (x.getName() != null) {
|
||||
print0(ucase ? "CONSTRAINT " : "constraint ");
|
||||
x.getName().accept(this);
|
||||
print(' ');
|
||||
}
|
||||
print0(ucase ? "NULL" : "null");
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(SQLUnionQuery x) {
|
||||
x.getLeft().accept(this);
|
||||
|
||||
@@ -716,4 +716,9 @@ public interface SQLASTVisitor {
|
||||
boolean visit(SQLErrorLoggingClause x);
|
||||
|
||||
void endVisit(SQLErrorLoggingClause x);
|
||||
|
||||
boolean visit(NullConstraint x);
|
||||
|
||||
void endVisit(NullConstraint x);
|
||||
|
||||
}
|
||||
|
||||
@@ -1565,4 +1565,13 @@ public class SQLASTVisitorAdapter implements SQLASTVisitor {
|
||||
public void endVisit(SQLErrorLoggingClause x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(NullConstraint x) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(NullConstraint x) {
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user