MCPcopy
hub / github.com/ent/ent / TestOrPredicates

Function TestOrPredicates

dialect/sql/sql_test.go:445–462  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

443}
444
445func TestOrPredicates(t *testing.T) {
446 s := Select("*").From(Table("users")).Where(EQ("name", "a8m"))
447 p := OrPredicates(
448 AndPredicates(
449 FieldEQ("a", "foo"),
450 FieldEQ("b", 1),
451 ),
452 func(s *Selector) {
453 petT := Table("pets").As("p")
454 s.Join(petT).On(petT.C("owner_id"), s.C("id"))
455 s.Where(EQ(petT.C("name"), "c"))
456 },
457 )
458 p(s)
459 query, args := s.Query()
460 require.Equal(t, "SELECT * FROM `users` JOIN `pets` AS `p` ON `p`.`owner_id` = `users`.`id` WHERE `name` = ? AND ((`users`.`a` = ? AND `users`.`b` = ?) OR `p`.`name` = ?)", query)
461 require.Equal(t, []any{"a8m", "foo", 1, "c"}, args)
462}
463
464func TestNotPredicates(t *testing.T) {
465 s := Select("*").From(Table("users")).Where(EQ("name", "a8m"))

Callers

nothing calls this directly

Calls 13

OrPredicatesFunction · 0.85
AndPredicatesFunction · 0.85
OnMethod · 0.80
SelectFunction · 0.70
TableFunction · 0.70
EQFunction · 0.70
FieldEQFunction · 0.70
WhereMethod · 0.65
CMethod · 0.65
QueryMethod · 0.65
FromMethod · 0.45
AsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…