mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
entc/gen: move predicates to mutation object (#825)
This commit is contained in:
@@ -7,6 +7,7 @@ in the LICENSE file in the root directory of this source tree.
|
||||
{{ define "dialect/sql/delete" }}
|
||||
{{ $builder := pascal $.Scope.Builder }}
|
||||
{{ $receiver := receiver $builder }}
|
||||
{{ $mutation := print $receiver ".mutation" }}
|
||||
|
||||
func ({{ $receiver}} *{{ $builder }}) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := &sqlgraph.DeleteSpec{
|
||||
@@ -18,7 +19,7 @@ func ({{ $receiver}} *{{ $builder }}) sqlExec(ctx context.Context) (int, error)
|
||||
},
|
||||
},
|
||||
}
|
||||
if ps := {{ $receiver }}.predicates; len(ps) > 0 {
|
||||
if ps := {{ $mutation }}.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
|
||||
@@ -31,7 +31,7 @@ func ({{ $receiver }} *{{ $builder }}) sqlSave(ctx context.Context) ({{ $ret }}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
{{- else }}
|
||||
if ps := {{ $receiver }}.predicates; len(ps) > 0 {
|
||||
if ps := {{ $mutation }}.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
|
||||
Reference in New Issue
Block a user