mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
bug fix for sql wall
This commit is contained in:
@@ -28,6 +28,7 @@ public interface SQLObject {
|
||||
void setParent(SQLObject parent);
|
||||
|
||||
Map<String, Object> getAttributes();
|
||||
boolean containsAttribute(String name);
|
||||
Object getAttribute(String name);
|
||||
void putAttribute(String name, Object value);
|
||||
Map<String, Object> getAttributesDirect();
|
||||
|
||||
@@ -88,6 +88,14 @@ public abstract class SQLObjectImpl implements SQLObject {
|
||||
return attributes;
|
||||
}
|
||||
|
||||
public boolean containsAttribute(String name) {
|
||||
if (attributes == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return attributes.containsKey(name);
|
||||
}
|
||||
|
||||
public Object getAttribute(String name) {
|
||||
if (attributes == null) {
|
||||
return null;
|
||||
|
||||
@@ -246,8 +246,8 @@ public class SQLEvalVisitorUtils {
|
||||
if (function != null) {
|
||||
Object result = function.eval(visitor, x);
|
||||
|
||||
if (result != SQLEvalVisitor.EVAL_ERROR) {
|
||||
x.getAttributes().put(EVAL_VALUE, result);
|
||||
if (result != SQLEvalVisitor.EVAL_ERROR && result != null) {
|
||||
x.putAttribute(EVAL_VALUE, result);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -744,7 +744,7 @@ public class SQLEvalVisitorUtils {
|
||||
public static boolean visit(SQLEvalVisitor visitor, SQLInListExpr x) {
|
||||
SQLExpr valueExpr = x.getExpr();
|
||||
valueExpr.accept(visitor);
|
||||
if (!valueExpr.getAttributes().containsKey(EVAL_VALUE)) {
|
||||
if (!valueExpr.containsAttribute(EVAL_VALUE)) {
|
||||
return false;
|
||||
}
|
||||
Object value = valueExpr.getAttribute(EVAL_VALUE);
|
||||
|
||||
@@ -31,7 +31,7 @@ public class Concat implements Function {
|
||||
for (SQLExpr item : x.getParameters()) {
|
||||
item.accept(visitor);
|
||||
|
||||
Object itemValue = item.getAttributes().get(EVAL_VALUE);
|
||||
Object itemValue = item.getAttribute(EVAL_VALUE);
|
||||
if (itemValue == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class Elt implements Function {
|
||||
param0IntValue = ((Number) param0Value).intValue();
|
||||
|
||||
if (param0IntValue >= x.getParameters().size()) {
|
||||
return null;
|
||||
return SQLEvalVisitor.EVAL_VALUE_NULL;
|
||||
}
|
||||
|
||||
SQLExpr item = x.getParameters().get(param0IntValue);
|
||||
|
||||
@@ -1573,7 +1573,7 @@ public class WallVisitorUtils {
|
||||
}
|
||||
|
||||
public static Object getValue(WallVisitor visitor, SQLExpr x) {
|
||||
if (x != null && x.getAttributes().containsKey(EVAL_VALUE)) {
|
||||
if (x != null && x.containsAttribute(EVAL_VALUE)) {
|
||||
return getValueFromAttributes(visitor, x);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user