mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved sql parser.
This commit is contained in:
@@ -33,6 +33,17 @@ public class SQLAssignItem extends SQLObjectImpl implements SQLReplaceable {
|
||||
setValue(value);
|
||||
}
|
||||
|
||||
public SQLAssignItem clone() {
|
||||
SQLAssignItem x = new SQLAssignItem();
|
||||
if (target != null) {
|
||||
x.setTarget(target.clone());
|
||||
}
|
||||
if (value != null) {
|
||||
x.setValue(value.clone());
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
public SQLExpr getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
@@ -57,4 +57,10 @@ public class SQLCheck extends SQLConstraintImpl implements SQLTableElement {
|
||||
expr = expr.clone();
|
||||
}
|
||||
}
|
||||
|
||||
public SQLCheck clone() {
|
||||
SQLCheck x = new SQLCheck();
|
||||
cloneTo(x);
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -737,4 +737,29 @@ public class SQLCreateTableStatement extends SQLStatementImpl implements SQLDDLS
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void cloneTo(SQLCreateTableStatement x) {
|
||||
x.ifNotExiists = ifNotExiists;
|
||||
x.type = type;
|
||||
if (tableSource != null) {
|
||||
x.setTableSource(tableSource.clone());
|
||||
}
|
||||
for (SQLTableElement e : tableElementList) {
|
||||
SQLTableElement e2 = e.clone();
|
||||
e2.setParent(x);
|
||||
x.tableElementList.add(e2);
|
||||
}
|
||||
if (inherits != null) {
|
||||
x.setInherits(inherits.clone());
|
||||
}
|
||||
if (select != null) {
|
||||
x.setSelect(select.clone());
|
||||
}
|
||||
}
|
||||
|
||||
public SQLCreateTableStatement clone() {
|
||||
SQLCreateTableStatement x = new SQLCreateTableStatement();
|
||||
cloneTo(x);
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,4 +27,10 @@ public class SQLPrimaryKeyImpl extends SQLUnique implements SQLPrimaryKey {
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
public SQLPrimaryKeyImpl clone() {
|
||||
SQLPrimaryKeyImpl x = new SQLPrimaryKeyImpl();
|
||||
cloneTo(x);
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,5 +18,5 @@ package com.alibaba.druid.sql.ast.statement;
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
|
||||
public interface SQLTableElement extends SQLObject {
|
||||
|
||||
SQLTableElement clone();
|
||||
}
|
||||
|
||||
@@ -72,6 +72,12 @@ public class SQLUnique extends SQLConstraintImpl implements SQLUniqueConstraint,
|
||||
}
|
||||
}
|
||||
|
||||
public SQLUnique clone() {
|
||||
SQLUnique x = new SQLUnique();
|
||||
cloneTo(x);
|
||||
return x;
|
||||
}
|
||||
|
||||
public void simplify() {
|
||||
super.simplify();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user