improve wall filter

This commit is contained in:
wenshao
2013-03-29 15:22:59 +08:00
parent 2b6e4bac08
commit 889c1e0ad7
2 changed files with 18 additions and 2 deletions
@@ -449,7 +449,7 @@ public class WallVisitorUtils {
}
if (leftResult == Boolean.TRUE) {
if (x.getParent() instanceof SQLExpr) {
if (!isFirst(x.getLeft())) {
final WallConditionContext current = wallConditionContextLocal.get();
if (current != null) {
current.setPartAlwayTrue(true);
@@ -475,6 +475,22 @@ public class WallVisitorUtils {
return SQLEvalVisitorUtils.eval(dbType, x, Collections.emptyList(), false);
}
public static boolean isFirst(SQLObject x) {
SQLObject parent = x.getParent();
if (!(parent instanceof SQLExpr)) {
return true;
}
if (parent instanceof SQLBinaryOpExpr) {
SQLBinaryOpExpr binaryExpr = (SQLBinaryOpExpr) parent;
if (isFirst(binaryExpr.getParent()) && x == binaryExpr.getLeft()) {
return true;
}
}
return false;
}
public static class WallConditionContext {