mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-08 01:28:24 +08:00
!14 QueryCondition.when(Predicate<T>),修复logic为like时value永远不为空
Merge pull request !14 from 落羽er/main
This commit is contained in:
commit
61e5657078
@ -118,7 +118,18 @@ public class QueryCondition implements Serializable {
|
||||
this.effective = fn.get();
|
||||
}
|
||||
public <T> QueryCondition when(Predicate<T> fn){
|
||||
this.effective = fn.test((T) value);
|
||||
Object val = this.value;
|
||||
if (LOGIC_LIKE.equals(logic)) {
|
||||
String valStr = (String) val;
|
||||
if (valStr.startsWith("%")) {
|
||||
valStr = valStr.substring(1);
|
||||
}
|
||||
if (valStr.endsWith("%")) {
|
||||
valStr = valStr.substring(0, valStr.length() - 1);
|
||||
}
|
||||
val = valStr;
|
||||
}
|
||||
this.effective = fn.test((T) val);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user