Skip to content

fix(sql): quote remaining reserved-word identifiers (key/value/trigger) - #688

Merged
think-back merged 1 commit into
mainfrom
fix/sql-reserved-word-quoting
Aug 11, 2026
Merged

fix(sql): quote remaining reserved-word identifiers (key/value/trigger)#688
think-back merged 1 commit into
mainfrom
fix/sql-reserved-word-quoting

Conversation

@think-back

Copy link
Copy Markdown
Collaborator

No description provided.

Follow-up to #687. With the fatal `trigger` parse error cleared,
startup progressed far enough to surface the next one:

  recall lifecycle enrollment maintenance failed: Error 1064
  near 'key = ? ORDER BY `options`.`key` LIMIT 1'

KEY and VALUE are reserved in MySQL 8.0, so raw-string predicates
like `WHERE key = ?` fail at parse time. GORM quotes identifiers it
builds itself, but not ones passed as literal SQL strings.

Quote all remaining bare occurrences (10 sites across 6 files),
including two `trigger` references inside JOIN/qualified predicates
that #687 missed because they carry a table prefix.

Verified: go build ./model/ ./service/ ./controller/ passes; a repo
wide re-scan finds no further bare reserved words in SQL strings.
@think-back
think-back merged commit 0b09d00 into main Aug 11, 2026
1 check passed
@KingCesc

Copy link
Copy Markdown

🤖 OpenCodeReview · 评审 commit 5bca23be · 共 1 条

controller/console_migrate.go

  • L100: [严重] 这里固定使用 MySQL/SQLite 的反引号引用列名,在 PostgreSQL 环境会生成非法 SQL(PostgreSQL 需要双引号),导致迁移接口执行删除旧配置时失败。建议使用 GORM 的结构化条件/按方言自动引用列名,避免跨数据库语法不兼容。
model.DB.Where(map[string]interface{}{"key": oldKeys}).Delete(&model.Option{})

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