-
Notifications
You must be signed in to change notification settings - Fork 200
FIX:rule_00112 中bigint和整数误触发 #3051
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
huajianxiaowanzi
wants to merge
2
commits into
actiontech:main
Choose a base branch
from
huajianxiaowanzi:llh
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+38
−34
Conversation
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
winfredLIN
reviewed
Jun 17, 2025
Comment on lines
-134
to
-159
switch node.Datum.Kind() { | ||
case types.KindInt64, types.KindUint64: | ||
return mysql.TypeLong, nil | ||
case types.KindFloat32, types.KindFloat64: | ||
return mysql.TypeDouble, nil | ||
case types.KindString: | ||
return mysql.TypeVarchar, nil | ||
case types.KindBytes: | ||
return mysql.TypeBlob, nil | ||
case types.KindBinaryLiteral: | ||
return mysql.TypeBit, nil | ||
case types.KindMysqlDecimal: | ||
return mysql.TypeNewDecimal, nil | ||
case types.KindMysqlDuration: | ||
return mysql.TypeDuration, nil | ||
case types.KindMysqlTime: | ||
return mysql.TypeDatetime, nil | ||
case types.KindMysqlEnum: | ||
return mysql.TypeEnum, nil | ||
case types.KindMysqlSet: | ||
return mysql.TypeSet, nil | ||
case types.KindMysqlJSON: | ||
return mysql.TypeJSON, nil | ||
default: | ||
return 0, fmt.Errorf("不支持的常量类型: %d", node.Datum.Kind()) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我们来理解一下这一条规则的用意:
在 MySQL 中,禁止WHERE子句中条件字段与值的数据类型不一致的一个原因有一些:
- 避免隐式类型转换带来的性能问题:SELECT * FROM users WHERE user_id = '123'; -- 索引失效
- 导致结果不准确或难以预料:SELECT * FROM users WHERE name = 123; -- 结果可能是错误的
从原始的代码上看,如:types.KindInt64, types.KindUint64,这两种类型都被认为是同一种,需要确认:
- 整数类型之间的比较一定不产生隐式转换吗?
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.
关联的 issue
#3049
描述你的变更
确认项(pr提交后操作)
Tip
请在指定复审人之前,确认并完成以下事项,完成后✅
not_compatible
need_update_doc