mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix db bug
This commit is contained in:
@@ -5,6 +5,7 @@ import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.text.StrSpliter;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.CharUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -444,7 +445,7 @@ public class Condition extends CloneSupport<Condition> {
|
||||
return;
|
||||
}
|
||||
|
||||
valueStr = valueStr.trim();
|
||||
valueStr = StrUtil.trim(valueStr);
|
||||
|
||||
// 处理null
|
||||
if (StrUtil.endWithIgnoreCase(valueStr, "null")) {
|
||||
@@ -463,7 +464,7 @@ public class Condition extends CloneSupport<Condition> {
|
||||
}
|
||||
}
|
||||
|
||||
List<String> strs = StrUtil.split(valueStr, StrUtil.C_SPACE, 2);
|
||||
final List<String> strs = StrUtil.split(valueStr, StrUtil.C_SPACE, 2);
|
||||
if (strs.size() < 2) {
|
||||
return;
|
||||
}
|
||||
@@ -472,7 +473,8 @@ public class Condition extends CloneSupport<Condition> {
|
||||
final String firstPart = strs.get(0).trim().toUpperCase();
|
||||
if (OPERATORS.contains(firstPart)) {
|
||||
this.operator = firstPart;
|
||||
this.value = strs.get(1).trim();
|
||||
// 比较符号后跟大部分为数字,此处做转换
|
||||
this.value = tryToNumber(strs.get(1));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -526,5 +528,20 @@ public class Condition extends CloneSupport<Condition> {
|
||||
}
|
||||
return value.substring(from, to);
|
||||
}
|
||||
|
||||
/**
|
||||
* 尝试转换为数字,转换失败返回字符串
|
||||
*
|
||||
* @param value 被转换的字符串值
|
||||
* @return 转换后的值
|
||||
*/
|
||||
private static Object tryToNumber(String value){
|
||||
value = StrUtil.trim(value);
|
||||
try{
|
||||
return NumberUtil.parseNumber(value);
|
||||
} catch (Exception ignore){
|
||||
return value;
|
||||
}
|
||||
}
|
||||
// ----------------------------------------------------------------------------------------------- Private method end
|
||||
}
|
||||
|
Reference in New Issue
Block a user