MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_issue_10125

Method test_issue_10125

test/orm/test_deferred.py:1740–1800  ·  view source on GitHub ↗
(self, load)

Source from the content-addressed store, hash-verified

1738
1739 @testing.variation("load", ["contains_eager", "joinedload"])
1740 def test_issue_10125(self, load):
1741 s = fixture_session()
1742
1743 employee_alias = aliased(Manager, flat=True)
1744 company_alias = aliased(Company)
1745
1746 if load.contains_eager:
1747 q = (
1748 s.query(company_alias)
1749 .outerjoin(
1750 employee_alias,
1751 company_alias.employees.of_type(employee_alias),
1752 )
1753 .options(
1754 contains_eager(
1755 company_alias.employees.of_type(employee_alias)
1756 ).load_only(
1757 employee_alias.person_id,
1758 )
1759 )
1760 )
1761 elif load.joinedload:
1762 q = s.query(company_alias).options(
1763 joinedload(
1764 company_alias.employees.of_type(employee_alias)
1765 ).load_only(
1766 employee_alias.person_id,
1767 )
1768 )
1769 else:
1770 load.fail()
1771
1772 if load.contains_eager:
1773 self.assert_compile(
1774 q,
1775 "SELECT people_1.person_id AS people_1_person_id, "
1776 "people_1.type AS people_1_type, "
1777 "managers_1.person_id AS managers_1_person_id, "
1778 "companies_1.company_id AS companies_1_company_id, "
1779 "companies_1.name AS companies_1_name "
1780 "FROM companies AS companies_1 LEFT OUTER JOIN "
1781 "(people AS people_1 JOIN managers AS managers_1 "
1782 "ON people_1.person_id = managers_1.person_id) "
1783 "ON companies_1.company_id = people_1.company_id",
1784 )
1785 elif load.joinedload:
1786 self.assert_compile(
1787 q,
1788 "SELECT companies_1.company_id AS companies_1_company_id, "
1789 "companies_1.name AS companies_1_name, "
1790 "people_1.person_id AS people_1_person_id, "
1791 "people_1.type AS people_1_type, "
1792 "managers_1.person_id AS managers_1_person_id "
1793 "FROM companies AS companies_1 LEFT OUTER JOIN "
1794 "(people AS people_1 JOIN managers AS managers_1 "
1795 "ON people_1.person_id = managers_1.person_id) "
1796 "ON companies_1.company_id = people_1.company_id "
1797 "ORDER BY people_1.person_id",

Callers

nothing calls this directly

Calls 11

fixture_sessionFunction · 0.90
aliasedFunction · 0.90
contains_eagerFunction · 0.90
joinedloadFunction · 0.90
load_onlyMethod · 0.80
assert_compileMethod · 0.80
optionsMethod · 0.45
outerjoinMethod · 0.45
queryMethod · 0.45
of_typeMethod · 0.45
failMethod · 0.45

Tested by

no test coverage detected