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

This commit is contained in:
Ariel Mashraki
2021-01-19 09:34:40 +02:00
committed by Ariel Mashraki
parent aa73b9067f
commit 63eb68a269
3 changed files with 9 additions and 2 deletions

View File

@@ -43,6 +43,12 @@ func ({{ $receiver }} *{{ $builder }}) createSpec() (*{{ $.Name }}, *sqlgraph.Cr
},
}
)
{{- /* Allow mutating the sqlgraph.CreateSpec by ent extensions or user templates.*/}}
{{- with $tmpls := matchTemplate "dialect/sql/create/spec/*" }}
{{- range $tmpl := $tmpls }}
{{- xtemplate $tmpl $ }}
{{- end }}
{{- end }}
{{- if $.ID.UserDefined }}
if id, ok := {{ $mutation }}.{{ $.ID.MutationGet }}(); ok {
_node.ID = id