MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_outerjoin_where_x2_t1t2t3

Method test_outerjoin_where_x2_t1t2t3

test/sql/test_query.py:1648–1679  ·  view source on GitHub ↗

Outer joins t1->t2,t3, where on t1, t2 and t3.

(self)

Source from the content-addressed store, hash-verified

1646 self.assertRows(expr, [(10, 20, 30), (11, 21, None)])
1647
1648 def test_outerjoin_where_x2_t1t2t3(self):
1649 """Outer joins t1->t2,t3, where on t1, t2 and t3."""
1650 t1, t2, t3 = self.tables("t1", "t2", "t3")
1651
1652 for criteria in (t2.c.t2_id == t3.c.t2_id, t3.c.t2_id == t2.c.t2_id):
1653 expr = (
1654 select(t1.c.t1_id, t2.c.t2_id, t3.c.t3_id)
1655 .where(
1656 and_(
1657 t1.c.name == "t1 #10",
1658 t2.c.name == "t2 #20",
1659 t3.c.name == "t3 #30",
1660 )
1661 )
1662 .select_from(
1663 t1.outerjoin(t2, t1.c.t1_id == t2.c.t1_id).outerjoin(
1664 t3, criteria
1665 )
1666 )
1667 )
1668 self.assertRows(expr, [(10, 20, 30)])
1669
1670 expr = (
1671 select(t1.c.t1_id, t2.c.t2_id, t3.c.t3_id)
1672 .where(and_(t1.c.t1_id < 19, t2.c.t2_id < 29, t3.c.t3_id < 39))
1673 .select_from(
1674 t1.outerjoin(t2, t1.c.t1_id == t2.c.t1_id).outerjoin(
1675 t3, criteria
1676 )
1677 )
1678 )
1679 self.assertRows(expr, [(10, 20, 30)])
1680
1681 def test_mixed(self):
1682 """Joins t1->t2, outer t2->t3."""

Callers

nothing calls this directly

Calls 6

assertRowsMethod · 0.95
selectFunction · 0.90
and_Function · 0.90
select_fromMethod · 0.45
whereMethod · 0.45
outerjoinMethod · 0.45

Tested by

no test coverage detected