feat(14.2.1-06): persist nested ML maps on relation-child create

RelationService looks up TranslationWriter like CRUDService so CreateChild can lift locale maps before fillChild, write Polish after the child PK, and return a hydrated title map.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Jakub Zych
2026-10-06 15:51:38 +02:00
parent f4bea33faf
commit 88a3a88876
5 changed files with 225 additions and 6 deletions

View File

@@ -165,6 +165,10 @@ func (s RelationService) CreateChild(ctx context.Context, cc *CompiledController
return lifecycleFailure(cc, err)
}
}
translations, err := liftMLValues(ctx, cr.child, in.Body, "create", s.writer, tx)
if err != nil {
return err
}
if err := s.fillChild(ctx, tx, cr.child, child, in.Body, "create"); err != nil {
return err
}
@@ -176,6 +180,9 @@ func (s RelationService) CreateChild(ctx context.Context, cc *CompiledController
if err := tx.WithContext(ctx).Create(child).Error; err != nil {
return lifecycleFailure(cc, err)
}
if err := applyMLTranslations(ctx, tx, s.writer, child, translations); err != nil {
return err
}
switch {
case parent.unsaved():
// The child exists now, unattached; the parent's first save
@@ -198,7 +205,10 @@ func (s RelationService) CreateChild(ctx context.Context, cc *CompiledController
}
}
result, err = projectFullRecord(ctx, tx, cr.child, child)
return err
if err != nil {
return err
}
return hydrateMLRecord(ctx, tx, cr.child, s.writer, child, result.Data, "create")
})
if err != nil {
return RecordResult{}, err