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:
@@ -23,6 +23,7 @@ public interface SQLForeignKeyConstraint extends SQLConstraint, SQLTableElement,
|
||||
|
||||
List<SQLName> getReferencingColumns();
|
||||
|
||||
SQLExprTableSource getReferencedTable();
|
||||
SQLName getReferencedTableName();
|
||||
|
||||
void setReferencedTableName(SQLName value);
|
||||
|
||||
@@ -22,12 +22,11 @@ import com.alibaba.druid.sql.ast.SQLName;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
public class SQLForeignKeyImpl extends SQLConstraintImpl implements SQLForeignKeyConstraint {
|
||||
|
||||
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;
|
||||
private SQLExprTableSource referencedTable;
|
||||
private List<SQLName> referencingColumns = new ArrayList<SQLName>();
|
||||
private List<SQLName> referencedColumns = new ArrayList<SQLName>();
|
||||
private boolean onDeleteCascade = false;
|
||||
private boolean onDeleteSetNull = false;
|
||||
|
||||
public SQLForeignKeyImpl(){
|
||||
|
||||
@@ -38,14 +37,33 @@ public class SQLForeignKeyImpl extends SQLConstraintImpl implements SQLForeignKe
|
||||
return referencingColumns;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SQLExprTableSource getReferencedTable() {
|
||||
return referencedTable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SQLName getReferencedTableName() {
|
||||
return referencedTableName;
|
||||
if (referencedTable == null) {
|
||||
return null;
|
||||
}
|
||||
return referencedTable.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReferencedTableName(SQLName value) {
|
||||
this.referencedTableName = value;
|
||||
if (value == null) {
|
||||
this.referencedTable = null;
|
||||
return;
|
||||
}
|
||||
this.setReferencedTable(new SQLExprTableSource(value));
|
||||
}
|
||||
|
||||
public void setReferencedTable(SQLExprTableSource x) {
|
||||
if (x != null) {
|
||||
x.setParent(this);
|
||||
}
|
||||
this.referencedTable = x;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -83,8 +101,8 @@ public class SQLForeignKeyImpl extends SQLConstraintImpl implements SQLForeignKe
|
||||
public void cloneTo(SQLForeignKeyImpl x) {
|
||||
super.cloneTo(x);
|
||||
|
||||
if (referencedTableName != null) {
|
||||
x.setReferencedTableName(referencedTableName.clone());
|
||||
if (referencedTable != null) {
|
||||
x.setReferencedTable(referencedTable.clone());
|
||||
}
|
||||
|
||||
for (SQLName column : referencingColumns) {
|
||||
|
||||
Reference in New Issue
Block a user