MCPcopy
hub / github.com/go-gorm/gorm / executeAssociationOperation

Method executeAssociationOperation

generics.go:745–757  ·  view source on GitHub ↗

executeAssociationOperation executes an association operation

(ctx context.Context, op clause.Association)

Source from the content-addressed store, hash-verified

743
744// executeAssociationOperation executes an association operation
745func (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
759func (s setCreateOrUpdateG[T]) handleAssociationCreate(ctx context.Context, base *DB, op clause.Association) error {
760 if len(op.Set) > 0 {

Callers 2

UpdateMethod · 0.95
CreateMethod · 0.95

Calls 4

handleAssociationMethod · 0.95
ModelMethod · 0.80
applyMethod · 0.80

Tested by

no test coverage detected