Merge pull request #1280 from tivenwang/dev

mysql select * frm aaa limit 20xxx ,limit后的字符串无法转换为数字的处理
This commit is contained in:
高铁
2016-06-20 21:51:44 +08:00
committed by GitHub
3 changed files with 37 additions and 2 deletions
@@ -15,6 +15,9 @@
*/
package com.alibaba.druid.sql.parser;
import com.alibaba.druid.util.StringUtils;
import org.apache.commons.lang.math.NumberUtils;
import static com.alibaba.druid.sql.parser.CharTypes.isFirstIdentifierChar;
import static com.alibaba.druid.sql.parser.CharTypes.isIdentifierChar;
import static com.alibaba.druid.sql.parser.CharTypes.isWhitespace;
@@ -1147,7 +1150,11 @@ public class Lexer {
}
public BigDecimal decimalValue() {
return new BigDecimal(subString(mark, bufPos).toCharArray());
String value = subString(mark, bufPos);
if (!NumberUtils.isNumber(value)){
throw new ParserException(value+" is not a number!");
}
return new BigDecimal(value.toCharArray());
}
public static interface CommentHandler {
@@ -95,7 +95,7 @@ public class StringUtils {
return a.equalsIgnoreCase(b);
}
public static boolean isEmpty(String value) {
public static boolean isEmpty(CharSequence value) {
if (value == null || value.length() == 0) {
return true;
}