improve sql parser

This commit is contained in:
yakolee
2014-06-04 18:27:31 +08:00
parent 7cdc26dc1d
commit b5daf4a8f5
3 changed files with 22 additions and 3 deletions
@@ -1239,6 +1239,14 @@ public class SQLEvalVisitorUtils {
return castToLong(list.get(0));
}
}
if (val instanceof Boolean) {
if (((Boolean) val).booleanValue()) {
return 1l;
} else {
return 0l;
}
}
return ((Number) val).longValue();
}
@@ -1431,6 +1439,10 @@ public class SQLEvalVisitorUtils {
return null;
}
if(a == EVAL_VALUE_NULL || b == EVAL_VALUE_NULL) {
return null;
}
if (a instanceof String) {
a = castToNumber((String) a);
}
@@ -42,8 +42,11 @@ public class Char implements Function {
int charCode = ((Number) paramValue).intValue();
buf.append((char) charCode);
} else if (paramValue instanceof String) {
int charCode = new BigDecimal((String)paramValue).intValue();
buf.append((char) charCode);
try {
int charCode = new BigDecimal((String) paramValue).intValue();
buf.append((char) charCode);
} catch (NumberFormatException e) {
}
} else {
return SQLEvalVisitor.EVAL_ERROR;
}