fix(model): resolve agent_custom_config length limit and SQL syntax i…#68
Open
qqpp13465 wants to merge 1 commit into
Open
fix(model): resolve agent_custom_config length limit and SQL syntax i…#68qqpp13465 wants to merge 1 commit into
qqpp13465 wants to merge 1 commit into
Conversation
…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>
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.
Summary
This PR fixes Issue #57 and several SQL syntax / chain-order bugs in
api/model/message.go, plus a minorindentation fix in
api/model/main.go.Changes
AgentCustomConfigGORM tag from the defaultvarchar(255)totype:text,resolving Issue 添加Dify智能体输入消息出错 #57 where Dify agent custom config JSON exceeds 255 characters and causes insert/update failures.
=?/LIKE?→= ?/LIKE ?) inGetMessagesByConversationIDandGetMessagesByConversationIDWithDirection.Find(&messages).Order(...)→Order(...).Find(&messages)socreated_time DESCsorting actually takes effect instead of being silentlyignored.
DingtalkCorpblock insidemigrateDB.Test Plan
AutoMigrateupgrades the existingagent_custom_configcolumn toTEXTon both SQLite and MySQL.created_time DESCby default.Fixes #57
cat > /tmp/pr_description_cn.md << 'EOF'
改动摘要
本次 PR 修复了 Issue #57 以及
api/model/message.go中多处 SQL 语法与链式调用顺序错误,同时修正了api/model/main.go中的一处缩进格式问题。
具体变更
AgentCustomConfig的 GORM 标签从默认varchar(255)改为type:text,彻底解决 Issue添加Dify智能体输入消息出错 #57 中 Dify 智能体自定义配置 JSON 超过 255 字符时保存失败的问题。
GetMessagesByConversationID和GetMessagesByConversationIDWithDirection中 SQL占位符前的空格缺失(
=?/LIKE?→= ?/LIKE ?)。Find(&messages).Order(...)→Order(...).Find(&messages),使created_time DESC降序排序真正生效,不再被静默忽略。migrateDB中DingtalkCorp代码块的缩进对齐。验证清单
AutoMigrate在 SQLite / MySQL 下均能将已有表的agent_custom_config字段升级为TEXT类型。created_time DESC正确排序。Fixes #57