fix(query): 修复QueryRuleEnum.NE规则导致ID首位字符丢失 #9312#9322
Open
jeecgai wants to merge 2 commits intojeecgboot:mainfrom
Open
fix(query): 修复QueryRuleEnum.NE规则导致ID首位字符丢失 #9312#9322jeecgai wants to merge 2 commits intojeecgboot:mainfrom
jeecgai wants to merge 2 commits intojeecgboot:mainfrom
Conversation
问题原因: - NE规则被错误地与LEFT_LIKE一起处理,导致value被substring(1)截取首字符 - 例如ID为2016032112479109121,查询时变成016032112479109121 修复方案: - 将NE规则单独处理 - 只有当值以感叹号开头时才进行截取
验证 jeecgboot#9312 修复: - 测试普通ID不被截取 - 测试!前缀正确截取 - 测试数字ID和字符串值
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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的自定义查询