Skip to content

Commit

Permalink
Merge pull request alibaba#478 from cutedemons/master
Browse files Browse the repository at this point in the history
fix SQLBinaryOpExpr split bug && modify wall config
  • Loading branch information
cutedemons committed Dec 11, 2013
2 parents 24382e7 + 16d3fe8 commit b2015a8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/main/java/com/alibaba/druid/sql/SQLUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ public static String buildToDate(String columnName, String tableAlias, String pa

public static List<SQLExpr> split(SQLBinaryOpExpr x) {
List<SQLExpr> groupList = new ArrayList<SQLExpr>();
groupList.add(x.getRight());

SQLExpr left = x.getLeft();
for (;;) {
if (left instanceof SQLBinaryOpExpr && ((SQLBinaryOpExpr) left).getOperator() == x.getOperator()) {
Expand All @@ -304,7 +306,6 @@ public static List<SQLExpr> split(SQLBinaryOpExpr x) {
break;
}
}
groupList.add(x.getRight());
return groupList;
}
}
10 changes: 5 additions & 5 deletions src/main/java/com/alibaba/druid/wall/WallConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,18 @@ public class WallConfig implements WallConfigMBean {
private boolean conditionOpXorAllow = false;
private boolean conditionOpBitwseAllow = true;

private boolean caseConditionAllow = false;
private boolean caseConditionConstAllow = false;

public WallConfig(){

}

public boolean isCaseConditionAllow() {
return caseConditionAllow;
public boolean isCaseConditionConstAllow() {
return caseConditionConstAllow;
}

public void setCaseConditionAllow(boolean caseConditionAllow) {
this.caseConditionAllow = caseConditionAllow;
public void setCaseConditionConstAllow(boolean caseConditionConstAllow) {
this.caseConditionConstAllow = caseConditionConstAllow;
}

public boolean isConditionDoubleConstAllow() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@ public static Object getValue(WallVisitor visitor, SQLExpr x) {

Object result = getValue(caseExpr);

if (visitor != null && !visitor.getConfig().isCaseConditionAllow()) {
if (visitor != null && !visitor.getConfig().isCaseConditionConstAllow()) {
boolean leftIsName = false;
if (x.getParent() instanceof SQLBinaryOpExpr) {
SQLExpr left = ((SQLBinaryOpExpr) x.getParent()).getLeft();
Expand Down Expand Up @@ -1083,7 +1083,7 @@ public static Object getValue(WallVisitor visitor, SQLExpr x) {

if (x instanceof SQLCaseExpr) {

if (visitor != null && !visitor.getConfig().isCaseConditionAllow()) {
if (visitor != null && !visitor.getConfig().isCaseConditionConstAllow()) {
SQLCaseExpr caseExpr = (SQLCaseExpr) x;

boolean leftIsName = false;
Expand Down

0 comments on commit b2015a8

Please sign in to comment.