executeAssociationOperation executes an association operation
(ctx context.Context, op clause.Association)
| 743 | |
| 744 | // executeAssociationOperation executes an association operation |
| 745 | func (s setCreateOrUpdateG[T]) executeAssociationOperation(ctx context.Context, op clause.Association) error { |
| 746 | var r T |
| 747 | base := s.c.g.apply(ctx).Model(r) |
| 748 | |
| 749 | switch op.Type { |
| 750 | case clause.OpCreate: |
| 751 | return s.handleAssociationCreate(ctx, base, op) |
| 752 | case clause.OpUnlink, clause.OpDelete, clause.OpUpdate: |
| 753 | return s.handleAssociation(ctx, base, op) |
| 754 | default: |
| 755 | return fmt.Errorf("unknown association operation type: %v", op.Type) |
| 756 | } |
| 757 | } |
| 758 | |
| 759 | func (s setCreateOrUpdateG[T]) handleAssociationCreate(ctx context.Context, base *DB, op clause.Association) error { |
| 760 | if len(op.Set) > 0 { |
no test coverage detected