mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
bugfix
This commit is contained in:
@@ -1418,6 +1418,18 @@ public class SQLEvalVisitorUtils {
|
||||
if (a == null || b == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if(a == EVAL_VALUE_NULL || b == EVAL_VALUE_NULL) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (a instanceof String) {
|
||||
a = castToNumber((String) a);
|
||||
}
|
||||
|
||||
if (b instanceof String) {
|
||||
b = castToNumber((String) b);
|
||||
}
|
||||
|
||||
if (a instanceof Long || b instanceof Long) {
|
||||
return castToLong(a).longValue() & castToLong(b).longValue();
|
||||
@@ -1503,7 +1515,18 @@ public class SQLEvalVisitorUtils {
|
||||
}
|
||||
|
||||
if (a instanceof Long || b instanceof Long) {
|
||||
return castToLong(a) / castToLong(b);
|
||||
Long longA = castToLong(a);
|
||||
Long longB = castToLong(b);
|
||||
if (longB == 0) {
|
||||
if (longA > 0) {
|
||||
return Double.POSITIVE_INFINITY;
|
||||
} else if (longA < 0) {
|
||||
return Double.NEGATIVE_INFINITY;
|
||||
} else {
|
||||
return Double.NaN;
|
||||
}
|
||||
}
|
||||
return longA / longB;
|
||||
}
|
||||
|
||||
if (a instanceof Integer || b instanceof Integer) {
|
||||
|
||||
@@ -50,7 +50,7 @@ public class Substring implements Function {
|
||||
|
||||
if (paramSize == 2) {
|
||||
|
||||
if (index < 0) {
|
||||
if (index <= 0) {
|
||||
int lastIndex = str.length() + index;
|
||||
return str.substring(lastIndex);
|
||||
}
|
||||
@@ -68,7 +68,7 @@ public class Substring implements Function {
|
||||
int len = ((Number) param2Value).intValue();
|
||||
|
||||
String result;
|
||||
if (index < 0) {
|
||||
if (index <= 0) {
|
||||
int lastIndex = str.length() + index;
|
||||
result = str.substring(lastIndex);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user