MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_outerjoin_where_x2_t1t2

Method test_outerjoin_where_x2_t1t2

test/sql/test_query.py:1620–1646  ·  view source on GitHub ↗

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

(self)

Source from the content-addressed store, hash-verified

1618 self.assertRows(expr, [(10, 20, 30)])
1619
1620 def test_outerjoin_where_x2_t1t2(self):
1621 """Outer joins t1->t2,t3, where on t1 and t2."""
1622
1623 t1, t2, t3 = self.tables("t1", "t2", "t3")
1624
1625 for criteria in (t2.c.t2_id == t3.c.t2_id, t3.c.t2_id == t2.c.t2_id):
1626 expr = (
1627 select(t1.c.t1_id, t2.c.t2_id, t3.c.t3_id)
1628 .where(and_(t1.c.name == "t1 #10", t2.c.name == "t2 #20"))
1629 .select_from(
1630 t1.outerjoin(t2, t1.c.t1_id == t2.c.t1_id).outerjoin(
1631 t3, criteria
1632 )
1633 )
1634 )
1635 self.assertRows(expr, [(10, 20, 30)])
1636
1637 expr = (
1638 select(t1.c.t1_id, t2.c.t2_id, t3.c.t3_id)
1639 .where(and_(t1.c.t1_id < 12, t2.c.t2_id < 39))
1640 .select_from(
1641 t1.outerjoin(t2, t1.c.t1_id == t2.c.t1_id).outerjoin(
1642 t3, criteria
1643 )
1644 )
1645 )
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."""

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