MCPcopy
hub / github.com/ent/ent / AndPredicates

Function AndPredicates

dialect/sql/sql.go:195–211  ·  view source on GitHub ↗

AndPredicates returns a new predicate for joining multiple generated predicates with AND between them.

(predicates ...P)

Source from the content-addressed store, hash-verified

193
194// AndPredicates returns a new predicate for joining multiple generated predicates with AND between them.
195func AndPredicates[P ~func(*Selector)](predicates ...P) func(*Selector) {
196 return func(s *Selector) {
197 s.CollectPredicates()
198 for _, p := range predicates {
199 p(s)
200 }
201 collected := s.CollectedPredicates()
202 s.UncollectedPredicates()
203 switch len(collected) {
204 case 0:
205 case 1:
206 s.Where(collected[0])
207 default:
208 s.Where(And(collected...))
209 }
210 }
211}
212
213// OrPredicates returns a new predicate for joining multiple generated predicates with OR between them.
214func OrPredicates[P ~func(*Selector)](predicates ...P) func(*Selector) {

Callers 15

AndFunction · 0.92
AndFunction · 0.92
AndFunction · 0.92
AndFunction · 0.92
AndFunction · 0.92
AndFunction · 0.92
AndFunction · 0.92
AndFunction · 0.92
AndFunction · 0.92
AndFunction · 0.92
AndFunction · 0.92
AndFunction · 0.92

Calls 5

CollectPredicatesMethod · 0.80
CollectedPredicatesMethod · 0.80
UncollectedPredicatesMethod · 0.80
AndFunction · 0.70
WhereMethod · 0.65

Tested by 2

TestAndPredicatesFunction · 0.68
TestOrPredicatesFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…