Skip to content

fix: 修复参数管理中使用参数键查询错误问题#2172

Open
WangHongshuo wants to merge 1 commit intoflipped-aurora:mainfrom
WangHongshuo:main
Open

fix: 修复参数管理中使用参数键查询错误问题#2172
WangHongshuo wants to merge 1 commit intoflipped-aurora:mainfrom
WangHongshuo:main

Conversation

@WangHongshuo
Copy link

问题描述:

【超级管理员】-【参数管理】中使用【参数键】作为查询条件报错:
image

Error 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key LIKE ? AND `sys_params`.`deleted_at` IS NULL' at line 1

运行环境:
win11
mysql 8.4.6

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

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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+"%")
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants