mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
bug fixed for 'null constraint' and 'default null'. issue #1349
This commit is contained in:
+2
-2
@@ -17,9 +17,9 @@ package com.alibaba.druid.sql.ast.statement;
|
||||
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
public class NotNullConstraint extends SQLConstraintImpl implements SQLColumnConstraint {
|
||||
public class SQLNotNullConstraint extends SQLConstraintImpl implements SQLColumnConstraint {
|
||||
|
||||
public NotNullConstraint(){
|
||||
public SQLNotNullConstraint(){
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -17,9 +17,9 @@ package com.alibaba.druid.sql.ast.statement;
|
||||
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
public class NullConstraint extends SQLConstraintImpl implements SQLColumnConstraint {
|
||||
public class SQLNullConstraint extends SQLConstraintImpl implements SQLColumnConstraint {
|
||||
|
||||
public NullConstraint(){
|
||||
public SQLNullConstraint(){
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -323,12 +323,8 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
}
|
||||
|
||||
if (x.getDefaultExpr() != null) {
|
||||
if (x.getDefaultExpr() instanceof SQLNullExpr) {
|
||||
print0(ucase ? " NULL" : " null");
|
||||
} else {
|
||||
print0(ucase ? " DEFAULT " : " default ");
|
||||
x.getDefaultExpr().accept(this);
|
||||
}
|
||||
print0(ucase ? " DEFAULT " : " default ");
|
||||
x.getDefaultExpr().accept(this);
|
||||
}
|
||||
|
||||
if (x.getStorage() != null) {
|
||||
|
||||
@@ -64,8 +64,8 @@ import com.alibaba.druid.sql.ast.expr.SQLSomeExpr;
|
||||
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.SQLNotNullConstraint;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLNullConstraint;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLAssignItem;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLCharacterDataType;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLCheck;
|
||||
@@ -1683,13 +1683,13 @@ public class SQLExprParser extends SQLParser {
|
||||
if (lexer.token() == Token.NOT) {
|
||||
lexer.nextToken();
|
||||
accept(Token.NULL);
|
||||
column.addConstraint(new NotNullConstraint());
|
||||
column.addConstraint(new SQLNotNullConstraint());
|
||||
return parseColumnRest(column);
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.NULL) {
|
||||
lexer.nextToken();
|
||||
column.getConstraints().add(new NullConstraint());
|
||||
column.getConstraints().add(new SQLNullConstraint());
|
||||
return parseColumnRest(column);
|
||||
}
|
||||
|
||||
@@ -1746,7 +1746,7 @@ public class SQLExprParser extends SQLParser {
|
||||
if (lexer.token() == Token.NOT) {
|
||||
lexer.nextToken();
|
||||
accept(Token.NULL);
|
||||
NotNullConstraint notNull = new NotNullConstraint();
|
||||
SQLNotNullConstraint notNull = new SQLNotNullConstraint();
|
||||
notNull.setName(name);
|
||||
column.addConstraint(notNull);
|
||||
return parseColumnRest(column);
|
||||
|
||||
@@ -1182,7 +1182,7 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Printab
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean visit(NotNullConstraint x) {
|
||||
public boolean visit(SQLNotNullConstraint x) {
|
||||
if (x.getName() != null) {
|
||||
print0(ucase ? "CONSTRAINT " : "constraint ");
|
||||
x.getName().accept(this);
|
||||
@@ -1192,7 +1192,7 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Printab
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean visit(NullConstraint x) {
|
||||
public boolean visit(SQLNullConstraint x) {
|
||||
if (x.getName() != null) {
|
||||
print0(ucase ? "CONSTRAINT " : "constraint ");
|
||||
x.getName().accept(this);
|
||||
|
||||
@@ -245,9 +245,9 @@ public interface SQLASTVisitor {
|
||||
|
||||
void endVisit(SQLCreateViewStatement.Column x);
|
||||
|
||||
boolean visit(NotNullConstraint x);
|
||||
boolean visit(SQLNotNullConstraint x);
|
||||
|
||||
void endVisit(NotNullConstraint x);
|
||||
void endVisit(SQLNotNullConstraint x);
|
||||
|
||||
void endVisit(SQLMethodInvokeExpr x);
|
||||
|
||||
@@ -717,8 +717,8 @@ public interface SQLASTVisitor {
|
||||
|
||||
void endVisit(SQLErrorLoggingClause x);
|
||||
|
||||
boolean visit(NullConstraint x);
|
||||
boolean visit(SQLNullConstraint x);
|
||||
|
||||
void endVisit(NullConstraint x);
|
||||
void endVisit(SQLNullConstraint x);
|
||||
|
||||
}
|
||||
|
||||
@@ -352,11 +352,11 @@ public class SQLASTVisitorAdapter implements SQLASTVisitor {
|
||||
public void endVisit(SQLCreateViewStatement.Column x) {
|
||||
}
|
||||
|
||||
public boolean visit(NotNullConstraint x) {
|
||||
public boolean visit(SQLNotNullConstraint x) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void endVisit(NotNullConstraint x) {
|
||||
public void endVisit(SQLNotNullConstraint x) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1567,11 +1567,11 @@ public class SQLASTVisitorAdapter implements SQLASTVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(NullConstraint x) {
|
||||
public boolean visit(SQLNullConstraint x) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(NullConstraint x) {
|
||||
public void endVisit(SQLNullConstraint x) {
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user