mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
entc/schema: adding support for immutable fields (#1340)
Summary: Pull Request resolved: https://github.com/facebookexternal/fbc/pull/1340 Immutable fields are ent fields which cannot be updated Reviewed By: a8m Differential Revision: D16899625 fbshipit-source-id: ca482c66570e84ca9a1e0a03f729847561f2816b
This commit is contained in:
committed by
Facebook Github Bot
parent
10b8c52363
commit
85b29631a8
@@ -60,7 +60,7 @@ func ({{ $receiver }} *{{ $builder }}) sqlSave(ctx context.Context) ({{ $ret }}
|
||||
res sql.Result
|
||||
builder = sql.Update({{ $.Package }}.Table).Where(sql.InInts({{ $.Package }}.{{ $.ID.Constant }}, ids...))
|
||||
)
|
||||
{{- range $_, $f := $.Fields }}
|
||||
{{- range $_, $f := $.MutableFields }}
|
||||
if {{ $receiver }}.{{ $f.StructField }} != nil {
|
||||
update = true
|
||||
builder.Set({{ $.Package }}.{{ $f.Constant }}, *{{ $receiver }}.{{ $f.StructField }})
|
||||
@@ -273,4 +273,4 @@ func ({{ $receiver }} *{{ $builder }}) sqlSave(ctx context.Context) ({{ $ret }}
|
||||
return {{/* return is not knwon at this point. */}}
|
||||
}
|
||||
{{- end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
Reference in New Issue
Block a user