mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
dialect/sql/sqlgraph: apply predicate on update-node
This commit is contained in:
committed by
Ariel Mashraki
parent
5e4d7dcbfc
commit
f315801779
@@ -30,15 +30,14 @@ func ({{ $receiver }} *{{ $builder }}) sqlSave(ctx context.Context) ({{ $ret }}
|
||||
return {{ $zero }}, &ValidationError{Name: "ID", err: fmt.Errorf("missing {{ $.Name }}.ID for update")}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
{{- else }}
|
||||
if ps := {{ $mutation }}.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
{{- end }}
|
||||
if ps := {{ $mutation }}.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
{{- end }}
|
||||
}
|
||||
{{- range $f := $.Fields }}
|
||||
{{- if or (not $f.Immutable) $f.UpdateDefault }}
|
||||
if value, ok := {{ $mutation }}.{{ $f.MutationGet }}(); ok {
|
||||
|
||||
Reference in New Issue
Block a user