Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a SQL syntax error that occurred when querying parameters by their key field in the parameter management feature. The error was caused by MySQL treating "key" as a reserved keyword.
Changes:
- Fixed SQL syntax error by escaping the reserved keyword "key" with backticks in the WHERE clause
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
| if info.Key != "" { | ||
| db = db.Where("key LIKE ?", "%"+info.Key+"%") | ||
| db = db.Where("`key` LIKE ?", "%"+info.Key+"%") |
There was a problem hiding this comment.
The fix for the reserved keyword issue is correct, but this functionality lacks test coverage. Consider adding tests for the GetSysParamsInfoList function, especially for the Key filter condition, to prevent similar issues in the future. Other services in this directory like auto_code_package and auto_code_template have corresponding test files.
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.
问题描述:
【超级管理员】-【参数管理】中使用【参数键】作为查询条件报错:

运行环境:
win11
mysql 8.4.6
修复方案:
server/service/system/sys_params.go:62
查询条件中的字符串key用反引号包裹