MCPcopy
hub / github.com/ent/ent / TestSelector_Intersect

Function TestSelector_Intersect

dialect/sql/builder_test.go:1633–1661  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1631}
1632
1633func TestSelector_Intersect(t *testing.T) {
1634 query, args := Dialect(dialect.Postgres).
1635 Select("*").
1636 From(Table("users")).
1637 Where(EQ("active", true)).
1638 Intersect(
1639 Select("*").
1640 From(Table("old_users1")).
1641 Where(
1642 And(
1643 EQ("is_active", true),
1644 GT("age", 20),
1645 ),
1646 ),
1647 ).
1648 IntersectAll(
1649 Select("*").
1650 From(Table("old_users2")).
1651 Where(
1652 And(
1653 EQ("is_active", "true"),
1654 LT("age", 18),
1655 ),
1656 ),
1657 ).
1658 Query()
1659 require.Equal(t, `SELECT * FROM "users" WHERE "active" INTERSECT SELECT * FROM "old_users1" WHERE "is_active" AND "age" > $1 INTERSECT ALL SELECT * FROM "old_users2" WHERE "is_active" = $2 AND "age" < $3`, query)
1660 require.Equal(t, []any{20, "true", 18}, args)
1661}
1662
1663func TestSelector_SetOperatorWithRecursive(t *testing.T) {
1664 t1, t2, t3 := Table("files"), Table("files"), Table("path")

Callers

nothing calls this directly

Calls 13

DialectFunction · 0.85
IntersectAllMethod · 0.80
IntersectMethod · 0.80
TableFunction · 0.70
EQFunction · 0.70
SelectFunction · 0.70
AndFunction · 0.70
GTFunction · 0.70
LTFunction · 0.70
QueryMethod · 0.65
WhereMethod · 0.65
FromMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…