entc/cmd/entc: support more numeric types for ids

Reviewed By: alexsn

Differential Revision: D17527952

fbshipit-source-id: 1465b054531cee8ca1dd445b6654063f32f4c4e3
This commit is contained in:
Ariel Mashraki
2019-09-23 09:46:48 -07:00
committed by Facebook Github Bot
parent 3f7553af20
commit 0f71ca6ad8
25 changed files with 2984 additions and 8 deletions

View File

@@ -40,7 +40,7 @@ func ({{ $receiver }} *{{ $builder }}) sqlSave(ctx context.Context) (*{{ $.Name
if err != nil {
return nil, rollback(tx, err)
}
{{ $.Receiver }}.ID = {{ if $.ID.IsString }}strconv.FormatInt(id, 10){{ else }}int(id){{ end }}
{{ $.Receiver }}.ID = {{ if $.ID.IsString }}strconv.FormatInt(id, 10){{ else }}{{ $.ID.Type }}(id){{ end }}
{{- range $_, $e := $.Edges }}
if len({{ $receiver }}.{{ $e.StructField }}) > 0 {
{{- if and $e.Unique $e.SelfRef }}{{/* O2O with self reference */}}