entc/gen: support setting GoType for integer IDs (#2657)

* Fix problem when model maps integer id to a GoType

* Update generated files

* apply suggestions from code review

* Update generated files

* Update generated files after merge from master

* Cleanup test code in integration

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>

* Modify integration test IntSID.

Wrapped tests of IntSID for avoid conflicts.

* Modify tests in integrations

Order of tests was changed. As a result, if-statement for difference in RDB is deleted.

+ force pushing same commit to invoke ci.

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>
This commit is contained in:
Reiji Tokuda
2022-07-04 13:50:51 +08:00
committed by GitHub
parent ed783dba70
commit 91b643091f
20 changed files with 3024 additions and 19 deletions

View File

@@ -180,7 +180,13 @@ func ({{ $receiver }} *{{ $builder }}) Save(ctx context.Context) ([]*{{ $.Name }
{{- if $.HasOneFieldID }}
mutation.{{ $.ID.BuilderField }} = &nodes[i].{{ $.ID.StructField }}
{{- if or $.ID.IsString $.ID.IsUUID $.ID.IsBytes $.ID.IsOther }}
{{- /* Do nothing, because these 2 types must be supplied by the user. */ -}}
{{- /* Do nothing, because these 4 types must be supplied by the user. */ -}}
{{- else if or $.ID.Type.ValueScanner }}
if specs[i].ID.Value != nil {
if err := nodes[i].ID.Scan(specs[i].ID.Value); err != nil {
return nil, err
}
}
{{- else }}
if specs[i].ID.Value != nil {{ if $.ID.UserDefined }}&& nodes[i].ID == 0{{ end }} {
id := specs[i].ID.Value.(int64)