feat(14.2.1-06): hydrate relation-child update and show ML maps

UpdateChild and ShowChild now lift, apply, and hydrate nested locales the same way as host CRUD, so a child form keeps English on the column and Polish through the writer.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Jakub Zych
2026-10-06 15:53:24 +02:00
parent 88a3a88876
commit 4e37d877f1
4 changed files with 49 additions and 6 deletions

View File

@@ -180,6 +180,36 @@ func TestRelationChildMLNestedSave(t *testing.T) {
t.Fatalf("Polish attributes = %#v", writer.attrs)
}
updated, err := svc.UpdateChild(context.Background(), cc, "entries", parent.ID, row.ID, RecordInput{Body: map[string]any{
"title": map[string]any{"en": "Hello", "pl": "Cześć"},
}})
if err != nil {
t.Fatalf("update: %v", err)
}
got, ok = updated.Data["title"].(map[string]string)
wantUpdated := map[string]string{"en": "Hello", "pl": "Cześć"}
if !ok || !reflect.DeepEqual(got, wantUpdated) {
t.Fatalf("update title = %#v", updated.Data["title"])
}
if err := db.First(&row, row.ID).Error; err != nil {
t.Fatal(err)
}
if row.Title != "Hello" {
t.Fatalf("host title after update = %q", row.Title)
}
if writer.attrs["pl"]["title"] != "Cześć" {
t.Fatalf("updated Polish attributes = %#v", writer.attrs)
}
shown, err := svc.ShowChild(context.Background(), cc, "entries", parent.ID, row.ID)
if err != nil {
t.Fatalf("show: %v", err)
}
got, ok = shown.Data["title"].(map[string]string)
if !ok || !reflect.DeepEqual(got, wantUpdated) {
t.Fatalf("show title = %#v", shown.Data["title"])
}
before := int64(0)
if err := db.Model(&mlEntry{}).Count(&before).Error; err != nil {
t.Fatal(err)