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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user