mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
entc: add idtype option codegen
Reviewed By: alexsn Differential Revision: D16601757 fbshipit-source-id: 35d5fbfb4ef40bae192e084ad4e067880175e71c
This commit is contained in:
committed by
Facebook Github Bot
parent
c203f043cf
commit
2cc8286f5f
@@ -26,7 +26,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 }}id{{ end }}
|
||||
{{ $.Receiver }}.ID = {{ if $.ID.IsString }}strconv.FormatInt(id, 10){{ else }}int(id){{ end }}
|
||||
{{- range $_, $e := $.Edges }}
|
||||
if len({{ $receiver }}.{{ $e.StructField }}) > 0 {
|
||||
{{- if and $e.Unique $e.SelfRef }}{{/* O2O with self reference */}}
|
||||
|
||||
@@ -21,9 +21,9 @@
|
||||
{{ if $.ID.IsString }}v[i], _ = strconv.Atoi({{ $arg }}[i]){{ else }}v[i] = {{ $arg }}[i]{{ end }}
|
||||
}
|
||||
{{- else if $.ID.IsString }}
|
||||
v, _ := strconv.Atoi({{ $arg }})
|
||||
id, _ := strconv.Atoi({{ $arg }})
|
||||
{{- end }}
|
||||
s.Where(sql.{{ $op.Name }}(s.C({{ $.ID.Constant }}), v{{ if $op.Variadic }}...{{ end }}))
|
||||
s.Where(sql.{{ $op.Name }}(s.C({{ $.ID.Constant }}), {{ if $op.Variadic }}v...{{ else }}id{{ end }}))
|
||||
}
|
||||
{{- end }}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user