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

This commit is contained in:
Ariel Mashraki
2021-01-19 09:42:00 +02:00
committed by Ariel Mashraki
parent d1db24d13f
commit 0f78dfe1c0
3 changed files with 9 additions and 2 deletions

File diff suppressed because one or more lines are too long

View File

@@ -168,6 +168,7 @@ var (
"dialect/additional/*",
"dialect/*/import/additional/*",
"dialect/*/*/spec/*",
"dialect/*/*/*/spec/*",
}
// templates holds the Go templates for the code generation.
templates *Template

View File

@@ -255,6 +255,12 @@ func ({{ $receiver }} *{{ $builder }}) sqlQuery() *sql.Selector {
return nil
},
}
{{- /* Allow mutating the sqlgraph.EdgeQuerySpec by ent extensions or user templates.*/}}
{{- with $tmpls := matchTemplate "dialect/sql/query/eagerloading/spec/*" }}
{{- range $tmpl := $tmpls }}
{{- xtemplate $tmpl $ }}
{{- end }}
{{- end }}
if err := sqlgraph.QueryEdges(ctx, {{ $receiver }}.driver, _spec); err != nil {
return nil, fmt.Errorf(`query edges "{{ $e.Name }}": %v`, err)
}