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:
@@ -25,7 +25,6 @@ import com.alibaba.druid.util.JdbcConstants;
|
||||
|
||||
public class MySqlKey extends SQLUnique implements SQLUniqueConstraint, SQLTableConstraint {
|
||||
|
||||
|
||||
private String indexType;
|
||||
|
||||
private boolean hasConstaint;
|
||||
@@ -66,4 +65,15 @@ public class MySqlKey extends SQLUnique implements SQLUniqueConstraint, SQLTable
|
||||
this.hasConstaint = hasConstaint;
|
||||
}
|
||||
|
||||
public void cloneTo(MySqlKey x) {
|
||||
super.cloneTo(x);
|
||||
x.indexType = indexType;
|
||||
x.hasConstaint = hasConstaint;
|
||||
}
|
||||
|
||||
public MySqlKey clone() {
|
||||
MySqlKey x = new MySqlKey();
|
||||
cloneTo(x);
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,4 +32,10 @@ public class MySqlPrimaryKey extends MySqlKey implements SQLPrimaryKey {
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
public MySqlPrimaryKey clone() {
|
||||
MySqlPrimaryKey x = new MySqlPrimaryKey();
|
||||
cloneTo(x);
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,4 +31,10 @@ public class MySqlUnique extends MySqlKey {
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
public MySqlUnique clone() {
|
||||
MySqlUnique x = new MySqlUnique();
|
||||
cloneTo(x);
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
+34
@@ -342,4 +342,38 @@ public class MySqlCreateTableStatement extends SQLCreateTableStatement implement
|
||||
public void output(StringBuffer buf) {
|
||||
this.accept(new MySqlOutputVisitor(buf));
|
||||
}
|
||||
|
||||
public void cloneTo(MySqlCreateTableStatement x) {
|
||||
super.cloneTo(x);
|
||||
for (Map.Entry<String, SQLObject> entry : tableOptions.entrySet()) {
|
||||
SQLObject obj = entry.getValue().clone();
|
||||
obj.setParent(x);
|
||||
x.tableOptions.put(entry.getKey(), obj);
|
||||
}
|
||||
if (partitioning != null) {
|
||||
x.setPartitioning(partitioning.clone());
|
||||
}
|
||||
for (SQLCommentHint hint : hints) {
|
||||
SQLCommentHint h2 = hint.clone();
|
||||
h2.setParent(x);
|
||||
x.hints.add(h2);
|
||||
}
|
||||
for (SQLCommentHint hint : optionHints) {
|
||||
SQLCommentHint h2 = hint.clone();
|
||||
h2.setParent(x);
|
||||
x.optionHints.add(h2);
|
||||
}
|
||||
if (like != null) {
|
||||
x.setLike(like.clone());
|
||||
}
|
||||
if (tableGroup != null) {
|
||||
x.setTableGroup(tableGroup.clone());
|
||||
}
|
||||
}
|
||||
|
||||
public MySqlCreateTableStatement clone() {
|
||||
MySqlCreateTableStatement x = new MySqlCreateTableStatement();
|
||||
cloneTo(x);
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
+14
@@ -59,4 +59,18 @@ public class MySqlPartitionByKey extends SQLPartitionBy implements MySqlObject {
|
||||
this.columns.add(column);
|
||||
}
|
||||
|
||||
public void cloneTo(MySqlPartitionByKey x) {
|
||||
super.cloneTo(x);
|
||||
for (SQLName column : columns) {
|
||||
SQLName c2 = column.clone();
|
||||
c2.setParent(x);
|
||||
x.columns.add(c2);
|
||||
}
|
||||
}
|
||||
|
||||
public MySqlPartitionByKey clone() {
|
||||
MySqlPartitionByKey x = new MySqlPartitionByKey();
|
||||
cloneTo(x);
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
+14
@@ -57,4 +57,18 @@ public class MySqlSubPartitionByKey extends SQLSubPartitionBy implements MySqlOb
|
||||
this.columns.add(column);
|
||||
}
|
||||
|
||||
public void cloneTo(MySqlSubPartitionByKey x) {
|
||||
super.cloneTo(x);
|
||||
for (SQLName column : columns) {
|
||||
SQLName c2 = column.clone();
|
||||
c2.setParent(x);
|
||||
x.columns.add(c2);
|
||||
}
|
||||
}
|
||||
|
||||
public MySqlSubPartitionByKey clone() {
|
||||
MySqlSubPartitionByKey x = new MySqlSubPartitionByKey();
|
||||
cloneTo(x);
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
+18
@@ -19,6 +19,7 @@ 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.ast.SQLSubPartitionBy;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLColumnDefinition;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.MySqlObject;
|
||||
@@ -72,4 +73,21 @@ public class MySqlSubPartitionByList extends SQLSubPartitionBy implements MySqlO
|
||||
this.columns.add(column);
|
||||
}
|
||||
|
||||
public void cloneTo(MySqlSubPartitionByList x) {
|
||||
super.cloneTo(x);
|
||||
if (expr != null) {
|
||||
x.setExpr(expr.clone());
|
||||
}
|
||||
for (SQLColumnDefinition column : columns) {
|
||||
SQLColumnDefinition c2 = column.clone();
|
||||
c2.setParent(x);
|
||||
x.columns.add(c2);
|
||||
}
|
||||
}
|
||||
|
||||
public MySqlSubPartitionByList clone() {
|
||||
MySqlSubPartitionByList x = new MySqlSubPartitionByList();
|
||||
cloneTo(x);
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.util.List;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLName;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLColumnDefinition;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLSelectOrderByItem;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLTableElement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.MySqlObjectImpl;
|
||||
@@ -69,4 +70,18 @@ public class MySqlTableIndex extends MySqlObjectImpl implements SQLTableElement
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
public MySqlTableIndex clone() {
|
||||
MySqlTableIndex x = new MySqlTableIndex();
|
||||
if (name != null) {
|
||||
x.setName(name.clone());
|
||||
}
|
||||
x.indexType = indexType;
|
||||
for (SQLSelectOrderByItem column : columns) {
|
||||
SQLSelectOrderByItem c2 = column.clone();
|
||||
c2.setParent(x);
|
||||
x.columns.add(c2);
|
||||
}
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user