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 (
|
||||
// CarDelete is the builder for deleting a Car entity.
|
||||
type CarDelete struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *CarMutation
|
||||
predicates []predicate.Car
|
||||
hooks []Hook
|
||||
mutation *CarMutation
|
||||
}
|
||||
|
||||
// Where adds a new predicate to the delete builder.
|
||||
func (cd *CarDelete) Where(ps ...predicate.Car) *CarDelete {
|
||||
cd.predicates = append(cd.predicates, ps...)
|
||||
cd.mutation.predicates = append(cd.mutation.predicates, ps...)
|
||||
return cd
|
||||
}
|
||||
|
||||
@@ -79,7 +78,7 @@ func (cd *CarDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
},
|
||||
},
|
||||
}
|
||||
if ps := cd.predicates; len(ps) > 0 {
|
||||
if ps := cd.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
|
||||
@@ -22,14 +22,13 @@ import (
|
||||
// CarUpdate is the builder for updating Car entities.
|
||||
type CarUpdate struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *CarMutation
|
||||
predicates []predicate.Car
|
||||
hooks []Hook
|
||||
mutation *CarMutation
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the builder.
|
||||
func (cu *CarUpdate) Where(ps ...predicate.Car) *CarUpdate {
|
||||
cu.predicates = append(cu.predicates, ps...)
|
||||
cu.mutation.predicates = append(cu.mutation.predicates, ps...)
|
||||
return cu
|
||||
}
|
||||
|
||||
@@ -137,7 +136,7 @@ func (cu *CarUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
},
|
||||
},
|
||||
}
|
||||
if ps := cu.predicates; len(ps) > 0 {
|
||||
if ps := cu.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -157,7 +156,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)
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
|
||||
"github.com/facebook/ent/examples/start/ent/car"
|
||||
"github.com/facebook/ent/examples/start/ent/group"
|
||||
"github.com/facebook/ent/examples/start/ent/predicate"
|
||||
"github.com/facebook/ent/examples/start/ent/user"
|
||||
|
||||
"github.com/facebook/ent"
|
||||
@@ -47,6 +48,7 @@ type CarMutation struct {
|
||||
clearedowner bool
|
||||
done bool
|
||||
oldValue func(context.Context) (*Car, error)
|
||||
predicates []predicate.Car
|
||||
}
|
||||
|
||||
var _ ent.Mutation = (*CarMutation)(nil)
|
||||
@@ -464,6 +466,7 @@ type GroupMutation struct {
|
||||
clearedusers bool
|
||||
done bool
|
||||
oldValue func(context.Context) (*Group, error)
|
||||
predicates []predicate.Group
|
||||
}
|
||||
|
||||
var _ ent.Mutation = (*GroupMutation)(nil)
|
||||
@@ -854,6 +857,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)
|
||||
|
||||
@@ -22,14 +22,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
|
||||
}
|
||||
|
||||
@@ -215,7 +214,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