ent: add AND operator for type predicates

Reviewed By: alexsn

Differential Revision: D16668249

fbshipit-source-id: 1554c3af9779fd551a90218c604d23b5bf8b8c6b
This commit is contained in:
Ariel Mashraki
2019-08-06 14:38:28 -07:00
committed by Facebook Github Bot
parent 4565455ee4
commit 2fd1b728f3
20 changed files with 348 additions and 71 deletions

View File

@@ -466,7 +466,18 @@ func AddressHasSuffix(v string) predicate.User {
)
}
// Or groups list of predicates with the or operator between them.
// And groups list of predicates with the AND operator between them.
func And(predicates ...predicate.User) predicate.User {
return predicate.User(
func(s *sql.Selector) {
for _, p := range predicates {
p(s)
}
},
)
}
// Or groups list of predicates with the OR operator between them.
func Or(predicates ...predicate.User) predicate.User {
return predicate.User(
func(s *sql.Selector) {

View File

@@ -109,7 +109,18 @@ func IDNotIn(ids ...int) predicate.Group {
)
}
// Or groups list of predicates with the or operator between them.
// And groups list of predicates with the AND operator between them.
func And(predicates ...predicate.Group) predicate.Group {
return predicate.Group(
func(s *sql.Selector) {
for _, p := range predicates {
p(s)
}
},
)
}
// Or groups list of predicates with the OR operator between them.
func Or(predicates ...predicate.Group) predicate.Group {
return predicate.Group(
func(s *sql.Selector) {

View File

@@ -109,7 +109,18 @@ func IDNotIn(ids ...int) predicate.Pet {
)
}
// Or groups list of predicates with the or operator between them.
// And groups list of predicates with the AND operator between them.
func And(predicates ...predicate.Pet) predicate.Pet {
return predicate.Pet(
func(s *sql.Selector) {
for _, p := range predicates {
p(s)
}
},
)
}
// Or groups list of predicates with the OR operator between them.
func Or(predicates ...predicate.Pet) predicate.Pet {
return predicate.Pet(
func(s *sql.Selector) {

View File

@@ -567,7 +567,18 @@ func BufferNotIn(vs ...[]byte) predicate.User {
)
}
// Or groups list of predicates with the or operator between them.
// And groups list of predicates with the AND operator between them.
func And(predicates ...predicate.User) predicate.User {
return predicate.User(
func(s *sql.Selector) {
for _, p := range predicates {
p(s)
}
},
)
}
// Or groups list of predicates with the OR operator between them.
func Or(predicates ...predicate.User) predicate.User {
return predicate.User(
func(s *sql.Selector) {