Skip to content

fix(model): resolve agent_custom_config length limit and SQL syntax i…#68

Open
qqpp13465 wants to merge 1 commit into
53AI:mainfrom
qqpp13465:analysis-branch
Open

fix(model): resolve agent_custom_config length limit and SQL syntax i…#68
qqpp13465 wants to merge 1 commit into
53AI:mainfrom
qqpp13465:analysis-branch

Conversation

@qqpp13465
Copy link
Copy Markdown

@qqpp13465 qqpp13465 commented May 19, 2026

Summary
This PR fixes Issue #57 and several SQL syntax / chain-order bugs in api/model/message.go, plus a minor
indentation fix in api/model/main.go.
Changes

  • fix(model/message.go):** Change AgentCustomConfig GORM tag from the default varchar(255) to type:text,
    resolving Issue 添加Dify智能体输入消息出错 #57 where Dify agent custom config JSON exceeds 255 characters and causes insert/update failures.
  • fix(model/message.go): Fix SQL placeholder spacing (=? / LIKE?= ? / LIKE ?) in
    GetMessagesByConversationID and GetMessagesByConversationIDWithDirection.
  • fix(model/message.go): Fix GORM chain-call order: Find(&messages).Order(...)
    Order(...).Find(&messages) so created_time DESC sorting actually takes effect instead of being silently
    ignored.
  • style(model/main.go): Correct indentation for the DingtalkCorp block inside migrateDB.

Test Plan

  • GORM AutoMigrate upgrades the existing agent_custom_config column to TEXT on both SQLite and MySQL.
  • Querying messages by conversation ID returns results sorted by created_time DESC by default.

Fixes #57

cat > /tmp/pr_description_cn.md << 'EOF'
改动摘要
本次 PR 修复了 Issue #57 以及 api/model/message.go 中多处 SQL 语法与链式调用顺序错误,同时修正了 api/model/main.go
中的一处缩进格式问题。

具体变更

  • fix(model/message.go): 将 AgentCustomConfig 的 GORM 标签从默认 varchar(255) 改为 type:text,彻底解决 Issue
    添加Dify智能体输入消息出错 #57 中 Dify 智能体自定义配置 JSON 超过 255 字符时保存失败的问题。
  • fix(model/message.go): 修正 GetMessagesByConversationIDGetMessagesByConversationIDWithDirection 中 SQL
    占位符前的空格缺失(=? / LIKE?= ? / LIKE ?)。
  • fix(model/message.go): 修正 GORM 链式调用顺序:Find(&messages).Order(...)Order(...).Find(&messages),使created_time DESC 降序排序真正生效,不再被静默忽略。
  • style(model/main.go): 修正 migrateDBDingtalkCorp 代码块的缩进对齐。

验证清单

  • GORM AutoMigrate 在 SQLite / MySQL 下均能将已有表的 agent_custom_config 字段升级为 TEXT 类型。
  • 按会话 ID 查询消息列表时,默认按 created_time DESC 正确排序。

Fixes #57

…ssues

- Change AgentCustomConfig from default varchar(255) to type:text to fix
  Issue 53AI#57 where Dify agent config exceeds 255 chars
- Fix SQL placeholder spacing: =? / LIKE? -> = ? / LIKE ?
- Fix GORM chain order: Find().Order() -> Order().Find() so DESC sorting works
- Fix indentation in migrateDB for DingtalkCorp block

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.

添加Dify智能体输入消息出错

1 participant