mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user