troyzhxu / bean-searcher

🔥🔥🔥 A read-only ORM focusing on advanced query, naturally supports joined tables, and avoids DTO/VO conversion, making it possible to realize complex query in one line of code !
https://bs.zhxu.cn
Apache License 2.0
1.25k stars 139 forks source link

同一个字段多个查询条件,为什么只有最后一个生效 #108

Open dazhaozhao opened 5 days ago

dazhaozhao commented 5 days ago

MapUtils.builder().field("A").sql("locate($1,'xxxx')>0").field("A").sql("length($1)=5").build() 结果SQL 只有 length(A)=5

image

有简化,咋个关闭简化?

troyzhxu commented 22 hours ago

同一个组内,同一个字段,field(..) 只会生效一次,你可以把它合并在一起:

MapUtils.builder()
        .field("A").sql("locate($1,'xxxx')>0 and length($1)=5")
        .build()

或者:

MapUtils.builder()
        .field("A").sql("locate($1,'xxxx')>0 or length($1)=5")
        .build()
troyzhxu commented 21 hours ago

有简化,咋个关闭简化?

目前尚未提供取消自动化简的功能。你为何要取消呢,可以描述一下你的使用场景 以及 取消的意义吗?