mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved mysql/oracle sql parser.
This commit is contained in:
@@ -50,4 +50,11 @@ public class SQLCheck extends SQLConstraintImpl implements SQLTableElement {
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
public void cloneTo(SQLCheck x) {
|
||||
super.cloneTo(x);
|
||||
|
||||
if (expr != null) {
|
||||
expr = expr.clone();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,8 @@ public class SQLColumnDefinition extends SQLObjectImpl implements SQLTableElemen
|
||||
protected SQLExpr comment;
|
||||
|
||||
protected Boolean enable;
|
||||
protected Boolean validate;
|
||||
protected Boolean rely;
|
||||
|
||||
// for mysql
|
||||
protected boolean autoIncrement = false;
|
||||
@@ -69,6 +71,22 @@ public class SQLColumnDefinition extends SQLObjectImpl implements SQLTableElemen
|
||||
this.enable = enable;
|
||||
}
|
||||
|
||||
public Boolean getValidate() {
|
||||
return validate;
|
||||
}
|
||||
|
||||
public void setValidate(Boolean validate) {
|
||||
this.validate = validate;
|
||||
}
|
||||
|
||||
public Boolean getRely() {
|
||||
return rely;
|
||||
}
|
||||
|
||||
public void setRely(Boolean rely) {
|
||||
this.rely = rely;
|
||||
}
|
||||
|
||||
public SQLName getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@ public abstract class SQLConstraintImpl extends SQLObjectImpl implements SQLCons
|
||||
|
||||
private SQLName name;
|
||||
private Boolean enable;
|
||||
private Boolean validate;
|
||||
private Boolean rely;
|
||||
|
||||
public List<SQLCommentHint> hints;
|
||||
|
||||
@@ -58,4 +60,25 @@ public abstract class SQLConstraintImpl extends SQLObjectImpl implements SQLCons
|
||||
this.enable = enable;
|
||||
}
|
||||
|
||||
public void cloneTo(SQLConstraint x) {
|
||||
if (name != null) {
|
||||
x.setName(name.clone());
|
||||
}
|
||||
}
|
||||
|
||||
public Boolean getValidate() {
|
||||
return validate;
|
||||
}
|
||||
|
||||
public void setValidate(Boolean validate) {
|
||||
this.validate = validate;
|
||||
}
|
||||
|
||||
public Boolean getRely() {
|
||||
return rely;
|
||||
}
|
||||
|
||||
public void setRely(Boolean rely) {
|
||||
this.rely = rely;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
public class SQLCreateViewStatement extends SQLStatementImpl implements SQLDDLStatement {
|
||||
|
||||
private boolean orReplace = false;
|
||||
private boolean force = false;
|
||||
protected SQLName name;
|
||||
protected SQLSelect subQuery;
|
||||
protected boolean ifNotExists = false;
|
||||
@@ -140,6 +141,14 @@ public class SQLCreateViewStatement extends SQLStatementImpl implements SQLDDLSt
|
||||
this.sqlSecurity = sqlSecurity;
|
||||
}
|
||||
|
||||
public boolean isForce() {
|
||||
return force;
|
||||
}
|
||||
|
||||
public void setForce(boolean force) {
|
||||
this.force = force;
|
||||
}
|
||||
|
||||
public void output(StringBuffer buf) {
|
||||
buf.append("CREATE VIEW ");
|
||||
this.name.output(buf);
|
||||
|
||||
@@ -26,6 +26,8 @@ public class SQLForeignKeyImpl extends SQLConstraintImpl implements SQLForeignKe
|
||||
private SQLName referencedTableName;
|
||||
private List<SQLName> referencingColumns = new ArrayList<SQLName>();
|
||||
private List<SQLName> referencedColumns = new ArrayList<SQLName>();
|
||||
private boolean onDeleteCascade = false;
|
||||
private boolean onDeleteSetNull = false;
|
||||
|
||||
public SQLForeignKeyImpl(){
|
||||
|
||||
@@ -51,6 +53,22 @@ public class SQLForeignKeyImpl extends SQLConstraintImpl implements SQLForeignKe
|
||||
return referencedColumns;
|
||||
}
|
||||
|
||||
public boolean isOnDeleteCascade() {
|
||||
return onDeleteCascade;
|
||||
}
|
||||
|
||||
public void setOnDeleteCascade(boolean onDeleteCascade) {
|
||||
this.onDeleteCascade = onDeleteCascade;
|
||||
}
|
||||
|
||||
public boolean isOnDeleteSetNull() {
|
||||
return onDeleteSetNull;
|
||||
}
|
||||
|
||||
public void setOnDeleteSetNull(boolean onDeleteSetNull) {
|
||||
this.onDeleteSetNull = onDeleteSetNull;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
if (visitor.visit(this)) {
|
||||
@@ -62,4 +80,23 @@ public class SQLForeignKeyImpl extends SQLConstraintImpl implements SQLForeignKe
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
public void cloneTo(SQLForeignKeyConstraint x) {
|
||||
super.cloneTo(x);
|
||||
|
||||
if (referencedTableName != null) {
|
||||
x.setReferencedTableName(referencedTableName.clone());
|
||||
}
|
||||
|
||||
for (SQLName column : referencingColumns) {
|
||||
SQLName columnClone = column.clone();
|
||||
columnClone.setParent(x);
|
||||
x.getReferencingColumns().add(columnClone);
|
||||
}
|
||||
|
||||
for (SQLName column : referencedColumns) {
|
||||
SQLName columnClone = column.clone();
|
||||
columnClone.setParent(x);
|
||||
x.getReferencedColumns().add(columnClone);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,11 +19,12 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLName;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
public class SQLUnique extends SQLConstraintImpl implements SQLUniqueConstraint, SQLTableElement {
|
||||
|
||||
private final List<SQLExpr> columns = new ArrayList<SQLExpr>();
|
||||
protected final List<SQLExpr> columns = new ArrayList<SQLExpr>();
|
||||
|
||||
public SQLUnique(){
|
||||
|
||||
@@ -49,4 +50,12 @@ public class SQLUnique extends SQLConstraintImpl implements SQLUniqueConstraint,
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
public void cloneTo(SQLUnique x) {
|
||||
super.cloneTo(x);
|
||||
|
||||
for (SQLExpr column : columns) {
|
||||
SQLExpr columnClone = column.clone();
|
||||
x.addColumn(columnClone);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user