entc/gen: make generated client to implement the ent.Mutator interface (#3161)

This commit is contained in:
Ariel Mashraki
2022-12-09 21:18:25 +02:00
committed by GitHub
parent 3f4916ff8b
commit d0c5afa705
85 changed files with 3522 additions and 22 deletions

View File

@@ -411,6 +411,11 @@ func (m *{{ $mutation }}) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *{{ $mutation }}) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation ({{ $n.Name }}).
func (m *{{ $mutation }}) Type() string {
return m.typ
@@ -479,7 +484,7 @@ func (m *{{ $mutation }}) SetField(name string, value ent.Value) error {
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.Set{{ $f.StructField }}(v)
m.{{ $f.MutationSet }}(v)
return nil
{{- end }}
}