dialect/sql/sqlgraph: add builders to create spec (#3288)

This commit is contained in:
Ariel Mashraki
2023-01-31 09:37:51 +02:00
committed by GitHub
parent a0fad09539
commit 037b5a4bc3
125 changed files with 134 additions and 854 deletions

View File

@@ -62,15 +62,7 @@ func ({{ $receiver }} *{{ $builder }}) sqlSave(ctx context.Context) (*{{ $.Name
func ({{ $receiver }} *{{ $builder }}) createSpec() (*{{ $.Name }}, *sqlgraph.CreateSpec) {
var (
_node = &{{ $.Name }}{config: {{ $receiver }}.config}
_spec = &sqlgraph.CreateSpec{
Table: {{ $.Package }}.Table,
{{- if $.HasOneFieldID }}
ID: &sqlgraph.FieldSpec{
Type: field.{{ $.ID.Type.ConstName }},
Column: {{ $.Package }}.{{ $.ID.Constant }},
},
{{- end }}
}
_spec = sqlgraph.NewCreateSpec({{ $.Package }}.Table, {{ if $.HasOneFieldID }}sqlgraph.NewFieldSpec({{ $.Package }}.{{ $.ID.Constant }}, field.{{ $.ID.Type.ConstName }}){{ else }}nil{{ end }})
)
{{- /* Allow mutating the sqlgraph.CreateSpec by ent extensions or user templates.*/}}
{{- with $tmpls := matchTemplate "dialect/sql/create/spec/*" }}