mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved sql parser schema repository.
This commit is contained in:
@@ -21,6 +21,7 @@ import java.util.*;
|
||||
import com.alibaba.druid.sql.SQLUtils;
|
||||
import com.alibaba.druid.sql.ast.*;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLMethodInvokeExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLPropertyExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.MySqlKey;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.MySqlPrimaryKey;
|
||||
@@ -235,6 +236,9 @@ public class SQLCreateTableStatement extends SQLStatementImpl implements SQLDDLS
|
||||
if (column instanceof SQLIdentifierExpr
|
||||
&& SQLUtils.nameEquals(columnName, ((SQLIdentifierExpr) column).getName())) {
|
||||
return unique.columns.size() > 1;
|
||||
} else if (column instanceof SQLMethodInvokeExpr
|
||||
&& SQLUtils.nameEquals(((SQLMethodInvokeExpr) column).getMethodName(), columnName)) {
|
||||
return true;
|
||||
}
|
||||
} else if (element instanceof MySqlKey) {
|
||||
MySqlKey unique = (MySqlKey) element;
|
||||
@@ -243,6 +247,9 @@ public class SQLCreateTableStatement extends SQLStatementImpl implements SQLDDLS
|
||||
if (column instanceof SQLIdentifierExpr
|
||||
&& SQLUtils.nameEquals(columnName, ((SQLIdentifierExpr) column).getName())) {
|
||||
return true;
|
||||
} else if (column instanceof SQLMethodInvokeExpr
|
||||
&& SQLUtils.nameEquals(((SQLMethodInvokeExpr) column).getMethodName(), columnName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -265,6 +272,9 @@ public class SQLCreateTableStatement extends SQLStatementImpl implements SQLDDLS
|
||||
if (column instanceof SQLIdentifierExpr
|
||||
&& SQLUtils.nameEquals(columnName, ((SQLIdentifierExpr) column).getName())) {
|
||||
return unique.columns.size() == 1;
|
||||
} else if (column instanceof SQLMethodInvokeExpr
|
||||
&& SQLUtils.nameEquals(((SQLMethodInvokeExpr) column).getMethodName(), columnName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +48,9 @@ public class SQLGrantStatement extends SQLStatementImpl {
|
||||
private boolean adminOption;
|
||||
|
||||
private SQLExpr identifiedBy;
|
||||
private String identifiedByPassword;
|
||||
|
||||
private boolean withGrantOption;
|
||||
|
||||
@Override
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
@@ -135,4 +138,20 @@ public class SQLGrantStatement extends SQLStatementImpl {
|
||||
public void setIdentifiedBy(SQLExpr identifiedBy) {
|
||||
this.identifiedBy = identifiedBy;
|
||||
}
|
||||
|
||||
public String getIdentifiedByPassword() {
|
||||
return identifiedByPassword;
|
||||
}
|
||||
|
||||
public void setIdentifiedByPassword(String identifiedByPassword) {
|
||||
this.identifiedByPassword = identifiedByPassword;
|
||||
}
|
||||
|
||||
public boolean getWithGrantOption() {
|
||||
return withGrantOption;
|
||||
}
|
||||
|
||||
public void setWithGrantOption(boolean withGrantOption) {
|
||||
this.withGrantOption = withGrantOption;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.alibaba.druid.sql.SQLUtils;
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLName;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLMethodInvokeExpr;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
public class SQLUnique extends SQLConstraintImpl implements SQLUniqueConstraint, SQLTableElement {
|
||||
@@ -122,6 +123,12 @@ public class SQLUnique extends SQLConstraintImpl implements SQLUniqueConstraint,
|
||||
columns.remove(i);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (expr instanceof SQLMethodInvokeExpr
|
||||
&& SQLUtils.nameEquals(((SQLMethodInvokeExpr) expr).getMethodName(), columnName.getSimpleName())) {
|
||||
columns.remove(i);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user