ability.go
9.53 KB
-
🐛 fix(ability): prevent duplicate (group, model) pairs when saving channels · 21523833When importing large model lists (≈700+) an attempt to save a channel could fail with: Error 1062 (23000): Duplicate entry 'default-DeepSeek-1' for key 'abilities.PRIMARY' Root cause: AddAbilities / UpdateAbilities inserted the same (group, model) pair multiple times if the input list contained duplicates or case-variants (e.g. `default` vs `Default`). Changes: • ability.go – AddAbilities: introduced `abilitySet` to deduplicate by lower-cased `group|model` key before batch-inserting. – UpdateAbilities: applied the same deduplication logic when rebuilding abilities inside a transaction. Notes: • The lower-casing is only for set comparison; the original `group` and `model` values are preserved when persisting to DB, so case sensitivity of stored data is unchanged. • Batch chunking logic (lo.Chunk) and performance characteristics remain unaffected. Fixes #1215Apple\Apple committed