entc/gen: support valuescanner in go-types (#510)

This commit is contained in:
Ariel Mashraki
2020-05-28 18:23:14 +03:00
committed by GitHub
parent ce89688d00
commit bf566aa3ac
24 changed files with 2580 additions and 34 deletions

View File

@@ -93,7 +93,7 @@ func ({{ $receiver }} *{{ $.Name }}) assignValues(values ...interface{}) error {
{{- $nulltype := $f.NullType -}}
if value, ok := values[{{ $i }}].(*{{ $nulltype }}); !ok {
return fmt.Errorf("unexpected type %T for field {{ $f.Name }}", values[{{ $i }}])
{{- if hasPrefix $nulltype "sql" }}
{{- if and (not $f.Type.ValueScanner) (hasPrefix $nulltype "sql") }}
} else if value.Valid {
{{- if $f.Nillable }}
{{ $ret }}.{{ $field }} = new({{ $f.Type }})