mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
entc/cmd/entc: support more numeric types for ids
Reviewed By: alexsn Differential Revision: D17527952 fbshipit-source-id: 1465b054531cee8ca1dd445b6654063f32f4c4e3
This commit is contained in:
committed by
Facebook Github Bot
parent
3f7553af20
commit
0f71ca6ad8
@@ -35,7 +35,7 @@ func ({{ $receiver }} *{{ $builder }}) sqlSave(ctx context.Context) ({{ $ret }}
|
||||
if err := {{ $.Receiver }}.FromRows(rows); err != nil {
|
||||
return {{ $zero }}, fmt.Errorf("{{ $pkg }}: failed scanning row into {{ $.Name }}: %v", err)
|
||||
}
|
||||
id = {{ $.Receiver }}.{{- if $.ID.IsString }}id(){{ else }}ID{{ end }}
|
||||
id = {{ if $.ID.IsString }}{{ $.Receiver }}.id(){{ else if not $.ID.IsInt }}int({{ $.Receiver }}.ID){{ else }}{{ $.Receiver }}.ID{{ end }}
|
||||
{{- else }}
|
||||
if err := rows.Scan(&id); err != nil {
|
||||
return {{ $zero }}, fmt.Errorf("{{ $pkg }}: failed reading id: %v", err)
|
||||
@@ -311,5 +311,7 @@ func ({{ $receiver }} *{{ $builder }}) sqlSave(ctx context.Context) ({{ $ret }}
|
||||
err = rollback(tx, serr)
|
||||
return {{/* return is not knwon at this point. */}}
|
||||
}
|
||||
{{- else if not $.Type.ID.IsInt }}
|
||||
eid := int(eid)
|
||||
{{- end }}
|
||||
{{ end }}
|
||||
|
||||
Reference in New Issue
Block a user