mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix db bug
This commit is contained in:
parent
95e0292757
commit
d615b5147b
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
# 5.5.9 (2021-02-20)
|
# 5.5.9 (2021-02-25)
|
||||||
|
|
||||||
### 新特性
|
### 新特性
|
||||||
* 【crypto 】 PemUtil.readPemKey支持EC(pr#1366@Github)
|
* 【crypto 】 PemUtil.readPemKey支持EC(pr#1366@Github)
|
||||||
@ -21,6 +21,7 @@
|
|||||||
* 【poi 】 修复ExcelPicUtil中图表报错问题(issue#I38857@Gitee)
|
* 【poi 】 修复ExcelPicUtil中图表报错问题(issue#I38857@Gitee)
|
||||||
* 【core 】 修复ListUtil.page方法返回空列表无法编辑问题(issue#1415@Github)
|
* 【core 】 修复ListUtil.page方法返回空列表无法编辑问题(issue#1415@Github)
|
||||||
* 【core 】 修复ListUtil.sub中step不通结果不一致问题(issue#1409@Github)
|
* 【core 】 修复ListUtil.sub中step不通结果不一致问题(issue#1409@Github)
|
||||||
|
* 【db 】 修复Condition转换参数值时未转换数字异常(issue#I38LTM@Gitee)
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import cn.hutool.core.convert.Convert;
|
|||||||
import cn.hutool.core.text.StrSpliter;
|
import cn.hutool.core.text.StrSpliter;
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
import cn.hutool.core.util.CharUtil;
|
import cn.hutool.core.util.CharUtil;
|
||||||
|
import cn.hutool.core.util.NumberUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -444,7 +445,7 @@ public class Condition extends CloneSupport<Condition> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
valueStr = valueStr.trim();
|
valueStr = StrUtil.trim(valueStr);
|
||||||
|
|
||||||
// 处理null
|
// 处理null
|
||||||
if (StrUtil.endWithIgnoreCase(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) {
|
if (strs.size() < 2) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -472,7 +473,8 @@ public class Condition extends CloneSupport<Condition> {
|
|||||||
final String firstPart = strs.get(0).trim().toUpperCase();
|
final String firstPart = strs.get(0).trim().toUpperCase();
|
||||||
if (OPERATORS.contains(firstPart)) {
|
if (OPERATORS.contains(firstPart)) {
|
||||||
this.operator = firstPart;
|
this.operator = firstPart;
|
||||||
this.value = strs.get(1).trim();
|
// 比较符号后跟大部分为数字,此处做转换
|
||||||
|
this.value = tryToNumber(strs.get(1));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -526,5 +528,20 @@ public class Condition extends CloneSupport<Condition> {
|
|||||||
}
|
}
|
||||||
return value.substring(from, to);
|
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
|
// ----------------------------------------------------------------------------------------------- Private method end
|
||||||
}
|
}
|
||||||
|
@ -52,4 +52,12 @@ public class ConditionTest {
|
|||||||
conditionBetween.setPlaceHolder(false);
|
conditionBetween.setPlaceHolder(false);
|
||||||
Assert.assertEquals("user BETWEEN 12 AND 13", conditionBetween.toString());
|
Assert.assertEquals("user BETWEEN 12 AND 13", conditionBetween.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void parseTest(){
|
||||||
|
final Condition age = Condition.parse("age", "< 10");
|
||||||
|
Assert.assertEquals("age < ?", age.toString());
|
||||||
|
// issue I38LTM
|
||||||
|
Assert.assertSame(Long.class, age.getValue().getClass());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user