mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
entc/gen/template: allow mutating the sqlgraph.CreateSpec by ent extensions or user templates
This commit is contained in:
committed by
Ariel Mashraki
parent
aa73b9067f
commit
63eb68a269
File diff suppressed because one or more lines are too long
@@ -167,6 +167,7 @@ var (
|
||||
partialPatterns = [...]string{
|
||||
"dialect/additional/*",
|
||||
"dialect/*/import/additional/*",
|
||||
"dialect/*/*/spec/*",
|
||||
}
|
||||
// templates holds the Go templates for the code generation.
|
||||
templates *Template
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user