mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improve sqlwall rule
This commit is contained in:
@@ -25,12 +25,12 @@ public interface SQLEvalVisitor extends SQLASTVisitor {
|
||||
public static final String EVAL_EXPR = "eval.expr";
|
||||
public static final Object EVAL_ERROR = new Object();
|
||||
public static final Object EVAL_VALUE_COUNT = new Object();
|
||||
public static final Object EVAL_VALUE_NULL = new Object();
|
||||
public static final Object EVAL_VALUE_NULL = new Object();
|
||||
|
||||
Function getFunction(String funcName);
|
||||
|
||||
void registerFunction(String funcName, Function function);
|
||||
|
||||
|
||||
void unregisterFunction(String funcName);
|
||||
|
||||
List<Object> getParameters();
|
||||
|
||||
@@ -704,7 +704,8 @@ public class SQLEvalVisitorUtils {
|
||||
|
||||
Object conditionValue = item.getConditionExpr().getAttribute(EVAL_VALUE);
|
||||
|
||||
if (eq(value, conditionValue)) {
|
||||
if ((x.getValueExpr() != null && eq(value, conditionValue))
|
||||
|| (x.getValueExpr() == null && conditionValue instanceof Boolean && (Boolean) conditionValue == Boolean.TRUE)) {
|
||||
item.getValueExpr().accept(visitor);
|
||||
|
||||
if (item.getValueExpr().getAttributes().containsKey(EVAL_VALUE)) {
|
||||
@@ -1051,6 +1052,8 @@ public class SQLEvalVisitorUtils {
|
||||
if (list.size() == 1) {
|
||||
return processValue(list.get(0));
|
||||
}
|
||||
} else if (value instanceof Date) {
|
||||
return ((Date) value).getTime();
|
||||
}
|
||||
return value;
|
||||
}
|
||||
@@ -1702,6 +1705,10 @@ public class SQLEvalVisitorUtils {
|
||||
return a;
|
||||
}
|
||||
|
||||
if (a == EVAL_VALUE_NULL || b == EVAL_VALUE_NULL) {
|
||||
return EVAL_VALUE_NULL;
|
||||
}
|
||||
|
||||
if (a instanceof Date || b instanceof Date) {
|
||||
return SQLEvalVisitor.EVAL_ERROR;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user