improved wallfilter. support update column check.

This commit is contained in:
wenshao
2017-08-14 16:09:35 +08:00
parent e1a6d99c1c
commit e210b1608a
22 changed files with 459 additions and 64 deletions
@@ -17,6 +17,8 @@ package com.alibaba.druid.sql.ast.statement;
import com.alibaba.druid.sql.ast.SQLExpr;
import com.alibaba.druid.sql.ast.SQLObjectImpl;
import com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr;
import com.alibaba.druid.sql.ast.expr.SQLPropertyExpr;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
public class SQLUpdateSetItem extends SQLObjectImpl {
@@ -60,4 +62,12 @@ public class SQLUpdateSetItem extends SQLObjectImpl {
visitor.endVisit(this);
}
public boolean columnMatch(String column) {
if (this.column instanceof SQLIdentifierExpr) {
return ((SQLIdentifierExpr) this.column).nameEquals(column);
} else if (this.column instanceof SQLPropertyExpr) {
((SQLPropertyExpr) this.column).nameEquals(column);
}
return false;
}
}
@@ -58,8 +58,14 @@ public class SQLUpdateStatement extends SQLStatementImpl implements SQLReplaceab
public SQLName getTableName() {
if (tableSource instanceof SQLExprTableSource) {
SQLExprTableSource exprTableSource = (SQLExprTableSource) tableSource;
return (SQLName) exprTableSource.getExpr();
return ((SQLExprTableSource) tableSource).getName();
}
if (tableSource instanceof SQLJoinTableSource) {
SQLTableSource left = ((SQLJoinTableSource) tableSource).getLeft();
if (left instanceof SQLExprTableSource) {
return ((SQLExprTableSource) left).getName();
}
}
return null;
}