MCPcopy
hub / github.com/ent/ent / TestAndPredicates

Function TestAndPredicates

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

Source from the content-addressed store, hash-verified

427}
428
429func TestAndPredicates(t *testing.T) {
430 s := Select("*").From(Table("users")).Where(EQ("name", "a8m"))
431 p := AndPredicates(
432 FieldEQ("a", "foo"),
433 FieldEQ("b", 1),
434 func(s *Selector) {
435 petT := Table("pets").As("p")
436 s.Join(petT).On(petT.C("owner_id"), s.C("id"))
437 },
438 )
439 p(s)
440 query, args := s.Query()
441 require.Equal(t, "SELECT * FROM `users` JOIN `pets` AS `p` ON `p`.`owner_id` = `users`.`id` WHERE `name` = ? AND (`users`.`a` = ? AND `users`.`b` = ?)", query)
442 require.Equal(t, []any{"a8m", "foo", 1}, args)
443}
444
445func TestOrPredicates(t *testing.T) {
446 s := Select("*").From(Table("users")).Where(EQ("name", "a8m"))

Callers

nothing calls this directly

Calls 12

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
JoinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…