mirror of
https://github.com/ent/ent.git
synced 2026-04-28 05:30:56 +03:00
entc/gen/template: allow mutating the sqlgraph.QuerySpec by ent extensions or user templates
This commit is contained in:
committed by
Ariel Mashraki
parent
d56537c606
commit
d1db24d13f
@@ -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 }})
|
||||
|
||||
Reference in New Issue
Block a user