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

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

View File

@@ -96,6 +96,12 @@ func ({{ $receiver }} *{{ $builder }}) querySpec() *sqlgraph.QuerySpec {
From: {{ $receiver }}.sql,
Unique: true,
}
{{- /* Allow mutating the sqlgraph.QuerySpec by ent extensions or user templates.*/}}
{{- with $tmpls := matchTemplate "dialect/sql/query/spec/*" }}
{{- range $tmpl := $tmpls }}
{{- xtemplate $tmpl $ }}
{{- end }}
{{- end }}
if fields := {{ $receiver }}.fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, {{ $.Package }}.{{ $.ID.Constant }})