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:
@@ -20,14 +20,13 @@ import (
|
||||
// GroupDelete is the builder for deleting a Group entity.
|
||||
type GroupDelete struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *GroupMutation
|
||||
predicates []predicate.Group
|
||||
hooks []Hook
|
||||
mutation *GroupMutation
|
||||
}
|
||||
|
||||
// Where adds a new predicate to the delete builder.
|
||||
func (gd *GroupDelete) Where(ps ...predicate.Group) *GroupDelete {
|
||||
gd.predicates = append(gd.predicates, ps...)
|
||||
gd.mutation.predicates = append(gd.mutation.predicates, ps...)
|
||||
return gd
|
||||
}
|
||||
|
||||
@@ -79,7 +78,7 @@ func (gd *GroupDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
},
|
||||
},
|
||||
}
|
||||
if ps := gd.predicates; len(ps) > 0 {
|
||||
if ps := gd.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
|
||||
@@ -21,14 +21,13 @@ import (
|
||||
// GroupUpdate is the builder for updating Group entities.
|
||||
type GroupUpdate struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *GroupMutation
|
||||
predicates []predicate.Group
|
||||
hooks []Hook
|
||||
mutation *GroupMutation
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the builder.
|
||||
func (gu *GroupUpdate) Where(ps ...predicate.Group) *GroupUpdate {
|
||||
gu.predicates = append(gu.predicates, ps...)
|
||||
gu.mutation.predicates = append(gu.mutation.predicates, ps...)
|
||||
return gu
|
||||
}
|
||||
|
||||
@@ -141,7 +140,7 @@ func (gu *GroupUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
},
|
||||
},
|
||||
}
|
||||
if ps := gu.predicates; len(ps) > 0 {
|
||||
if ps := gu.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/facebook/ent/examples/m2m2types/ent/group"
|
||||
"github.com/facebook/ent/examples/m2m2types/ent/predicate"
|
||||
"github.com/facebook/ent/examples/m2m2types/ent/user"
|
||||
|
||||
"github.com/facebook/ent"
|
||||
@@ -44,6 +45,7 @@ type GroupMutation struct {
|
||||
clearedusers bool
|
||||
done bool
|
||||
oldValue func(context.Context) (*Group, error)
|
||||
predicates []predicate.Group
|
||||
}
|
||||
|
||||
var _ ent.Mutation = (*GroupMutation)(nil)
|
||||
@@ -431,6 +433,7 @@ type UserMutation struct {
|
||||
clearedgroups bool
|
||||
done bool
|
||||
oldValue func(context.Context) (*User, error)
|
||||
predicates []predicate.User
|
||||
}
|
||||
|
||||
var _ ent.Mutation = (*UserMutation)(nil)
|
||||
|
||||
@@ -20,14 +20,13 @@ import (
|
||||
// UserDelete is the builder for deleting a User entity.
|
||||
type UserDelete struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *UserMutation
|
||||
predicates []predicate.User
|
||||
hooks []Hook
|
||||
mutation *UserMutation
|
||||
}
|
||||
|
||||
// Where adds a new predicate to the delete builder.
|
||||
func (ud *UserDelete) Where(ps ...predicate.User) *UserDelete {
|
||||
ud.predicates = append(ud.predicates, ps...)
|
||||
ud.mutation.predicates = append(ud.mutation.predicates, ps...)
|
||||
return ud
|
||||
}
|
||||
|
||||
@@ -79,7 +78,7 @@ func (ud *UserDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
},
|
||||
},
|
||||
}
|
||||
if ps := ud.predicates; len(ps) > 0 {
|
||||
if ps := ud.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
|
||||
@@ -21,14 +21,13 @@ import (
|
||||
// UserUpdate is the builder for updating User entities.
|
||||
type UserUpdate struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *UserMutation
|
||||
predicates []predicate.User
|
||||
hooks []Hook
|
||||
mutation *UserMutation
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the builder.
|
||||
func (uu *UserUpdate) Where(ps ...predicate.User) *UserUpdate {
|
||||
uu.predicates = append(uu.predicates, ps...)
|
||||
uu.mutation.predicates = append(uu.mutation.predicates, ps...)
|
||||
return uu
|
||||
}
|
||||
|
||||
@@ -154,7 +153,7 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
},
|
||||
},
|
||||
}
|
||||
if ps := uu.predicates; len(ps) > 0 {
|
||||
if ps := uu.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