[#7689] fixed indexes update collection error

This commit is contained in:
Gani Georgiev
2026-05-14 21:32:21 +03:00
parent 9d50e20880
commit 8d7e3abbd6
8 changed files with 225 additions and 2 deletions
+20
View File
@@ -348,6 +348,7 @@ func (app *BaseApp) registerCollectionHooks() {
}
// @todo experiment eventually replacing the rules *string with a struct?
// @todo consider changing the Indexes field to a "getter" for the sqlite_master table?
type baseCollection struct {
BaseModel
@@ -820,6 +821,25 @@ func onCollectionSave(e *CollectionEvent) error {
e.Collection.updateGeneratedIdIfExists(e.App)
// normalize indexes table name
for i, raw := range e.Collection.Indexes {
parsed := dbutils.ParseIndex(raw)
// no need to normalize
if parsed.TableName == e.Collection.Name {
continue
}
parsed.TableName = e.Collection.Name
normalized := parsed.Build()
if normalized == "" {
continue // leave to the model validator to decide whether to return an error
}
e.Collection.Indexes[i] = normalized
}
return e.Next()
}