MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / test_mixed_where

Method test_mixed_where

test/sql/test_query.py:1760–1821  ·  view source on GitHub ↗

Joins t1->t2, outer t2->t3, plus a where on each table in turn.

(self)

Source from the content-addressed store, hash-verified

1758 self.assertRows(expr, [(10, 20, 30), (11, 21, None)])
1759
1760 def test_mixed_where(self):
1761 """Joins t1->t2, outer t2->t3, plus a where on each table in turn."""
1762 t1, t2, t3 = self.tables("t1", "t2", "t3")
1763
1764 for criteria in (t2.c.t2_id == t3.c.t2_id, t3.c.t2_id == t2.c.t2_id):
1765 expr = (
1766 select(t1.c.t1_id, t2.c.t2_id, t3.c.t3_id)
1767 .where(
1768 t1.c.name == "t1 #10",
1769 )
1770 .select_from(t1.join(t2).outerjoin(t3, criteria))
1771 )
1772 self.assertRows(expr, [(10, 20, 30)])
1773
1774 expr = (
1775 select(t1.c.t1_id, t2.c.t2_id, t3.c.t3_id)
1776 .where(
1777 t2.c.name == "t2 #20",
1778 )
1779 .select_from(t1.join(t2).outerjoin(t3, criteria))
1780 )
1781 self.assertRows(expr, [(10, 20, 30)])
1782
1783 expr = (
1784 select(t1.c.t1_id, t2.c.t2_id, t3.c.t3_id)
1785 .where(
1786 t3.c.name == "t3 #30",
1787 )
1788 .select_from(t1.join(t2).outerjoin(t3, criteria))
1789 )
1790 self.assertRows(expr, [(10, 20, 30)])
1791
1792 expr = (
1793 select(t1.c.t1_id, t2.c.t2_id, t3.c.t3_id)
1794 .where(
1795 and_(t1.c.name == "t1 #10", t2.c.name == "t2 #20"),
1796 )
1797 .select_from(t1.join(t2).outerjoin(t3, criteria))
1798 )
1799 self.assertRows(expr, [(10, 20, 30)])
1800
1801 expr = (
1802 select(t1.c.t1_id, t2.c.t2_id, t3.c.t3_id)
1803 .where(
1804 and_(t2.c.name == "t2 #20", t3.c.name == "t3 #30"),
1805 )
1806 .select_from(t1.join(t2).outerjoin(t3, criteria))
1807 )
1808 self.assertRows(expr, [(10, 20, 30)])
1809
1810 expr = (
1811 select(t1.c.t1_id, t2.c.t2_id, t3.c.t3_id)
1812 .where(
1813 and_(
1814 t1.c.name == "t1 #10",
1815 t2.c.name == "t2 #20",
1816 t3.c.name == "t3 #30",
1817 ),

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected