mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
entc/gen: fix update ids check bug in user-defined-ids
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/203 Reviewed By: alexsn Differential Revision: D18725824 fbshipit-source-id: 888686bb5fa87649be89ec1926cbd7a3b6cf7932
This commit is contained in:
committed by
Facebook Github Bot
parent
ed3747ff82
commit
5fe9fcdc1b
@@ -75,14 +75,14 @@ func ({{ $receiver }} *{{ $builder }}) sqlSave(ctx context.Context) ({{ $ret }}
|
||||
res sql.Result
|
||||
updater = builder.Update({{ $.Package }}.Table)
|
||||
)
|
||||
{{- if $.ID.IsInt }}
|
||||
updater = updater.Where(sql.InInts({{ $.Package }}.{{ $.ID.Constant }}, ids...))
|
||||
{{- else }}
|
||||
{{- if and (not $.ID.IsInt) $.ID.UserDefined }}
|
||||
idface := make([]interface{}, len(ids))
|
||||
for i := range ids {
|
||||
idface[i] = ids[i]
|
||||
}
|
||||
updater = updater.Where(sql.In({{ $.Package }}.{{ $.ID.Constant }}, idface...))
|
||||
{{- else }}
|
||||
updater = updater.Where(sql.InInts({{ $.Package }}.{{ $.ID.Constant }}, ids...))
|
||||
{{- end }}
|
||||
{{- range $_, $f := $.Fields }}
|
||||
{{- if or (not $f.Immutable) $f.UpdateDefault }}
|
||||
|
||||
Reference in New Issue
Block a user