(ctx context.Context, base *DB, op clause.Association)
| 757 | } |
| 758 | |
| 759 | func (s setCreateOrUpdateG[T]) handleAssociationCreate(ctx context.Context, base *DB, op clause.Association) error { |
| 760 | if len(op.Set) > 0 { |
| 761 | return s.handleAssociationForOwners(base, ctx, func(owner T, assoc *Association) error { |
| 762 | data := make(map[string]interface{}, len(op.Set)) |
| 763 | for _, a := range op.Set { |
| 764 | data[a.Column.Name] = a.Value |
| 765 | } |
| 766 | return assoc.Append(data) |
| 767 | }, op.Association) |
| 768 | } |
| 769 | |
| 770 | return s.handleAssociationForOwners(base, ctx, func(owner T, assoc *Association) error { |
| 771 | return assoc.Append(op.Values...) |
| 772 | }, op.Association) |
| 773 | } |
| 774 | |
| 775 | // handleAssociationForOwners is a helper function that handles associations for all owners |
| 776 | func (s setCreateOrUpdateG[T]) handleAssociationForOwners(base *DB, ctx context.Context, handler func(owner T, association *Association) error, associationName string) error { |
no test coverage detected