fix(query): 修复QueryRuleEnum.NE规则导致ID首位字符丢失 #9312 #9322
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
问题描述
修复 #9312
使用
QueryGenerator.initQueryWrapper自定义查询规则时,如果使用QueryRuleEnum.NE条件会导致ID首位字符丢失。例如:实际ID为
2016032112479109121,最终执行的条件变成WHERE (id <> '016032112479109121')问题原因
在
QueryGenerator.java第579行,NE规则被错误地与LEFT_LIKE一起处理:LEFT_LIKE需要截取首字符(去掉*通配符),但NE不应该这样处理。修复方案
将
NE规则单独处理,只有当值以!开头时才进行截取:测试验证
已添加单元测试
QueryRuleEnumNETest.java:影响范围
QueryRuleEnum.NE的自定义查询