entc/gen/template: allow mutating the sqlgraph.UpdateSpec by ent extensions or user templates

This commit is contained in:
Ariel Mashraki
2021-01-19 09:38:28 +02:00
committed by Ariel Mashraki
parent 7f5720cf92
commit d56537c606
2 changed files with 8 additions and 2 deletions

View File

@@ -24,6 +24,12 @@ func ({{ $receiver }} *{{ $builder }}) sqlSave(ctx context.Context) ({{ $ret }}
},
},
}
{{- /* Allow mutating the sqlgraph.UpdateSpec by ent extensions or user templates.*/}}
{{- with $tmpls := matchTemplate "dialect/sql/update/spec/*" }}
{{- range $tmpl := $tmpls }}
{{- xtemplate $tmpl $ }}
{{- end }}
{{- end }}
{{- if $one }}
id, ok := {{ $mutation }}.{{ $.ID.MutationGet }}()
if !ok {