MCPcopy
hub / github.com/ent/ent / OrPredicates

Function OrPredicates

dialect/sql/sql.go:214–230  ·  view source on GitHub ↗

OrPredicates returns a new predicate for joining multiple generated predicates with OR between them.

(predicates ...P)

Source from the content-addressed store, hash-verified

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) {
215 return func(s *Selector) {
216 s.CollectPredicates()
217 for _, p := range predicates {
218 p(s)
219 }
220 collected := s.CollectedPredicates()
221 s.UncollectedPredicates()
222 switch len(collected) {
223 case 0:
224 case 1:
225 s.Where(collected[0])
226 default:
227 s.Where(Or(collected...))
228 }
229 }
230}
231
232// NotPredicates wraps the generated predicates with NOT. For example, NOT(P), NOT((P1 AND P2)).
233func NotPredicates[P ~func(*Selector)](predicates ...P) func(*Selector) {

Callers 15

OrFunction · 0.92
OrFunction · 0.92
OrFunction · 0.92
OrFunction · 0.92
OrFunction · 0.92
OrFunction · 0.92
OrFunction · 0.92
OrFunction · 0.92
OrFunction · 0.92
OrFunction · 0.92
OrFunction · 0.92
OrFunction · 0.92

Calls 5

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

Tested by 1

TestOrPredicatesFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…