entc/gen: add support for ValueScanner for int type (#530)

This commit is contained in:
Ariel Mashraki
2020-06-08 14:54:37 +03:00
committed by GitHub
parent 59b880a6ba
commit 86d345e187
22 changed files with 2299 additions and 41 deletions

View File

@@ -39,7 +39,7 @@ func ({{ $receiver }} *{{ $builder }}) sqlSave(ctx context.Context) ({{ $ret }}
}
}
{{- end }}
{{- range $_, $f := $.Fields }}
{{- range $f := $.Fields }}
{{- if or (not $f.Immutable) $f.UpdateDefault }}
if value, ok := {{ $mutation }}.{{ $f.MutationGet }}(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
@@ -48,7 +48,7 @@ func ({{ $receiver }} *{{ $builder }}) sqlSave(ctx context.Context) ({{ $ret }}
Column: {{ $.Package }}.{{ $f.Constant }},
})
}
{{- if $f.Type.Numeric }}
{{- if and $f.Type.Numeric $f.ConvertedToBasic }}
if value, ok := {{ $mutation }}.Added{{ $f.StructField }}(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.{{ $f.Type.ConstName }},