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

Method test_lazy_options

test/orm/test_options.py:1828–1859  ·  view source on GitHub ↗

An eager relationship can be upgraded to a lazy relationship.

(self)

Source from the content-addressed store, hash-verified

1826 self.assert_sql_count(testing.db, go, 6)
1827
1828 def test_lazy_options(self):
1829 """An eager relationship can be upgraded to a lazy relationship."""
1830
1831 Address, addresses, users, User = (
1832 self.classes.Address,
1833 self.tables.addresses,
1834 self.tables.users,
1835 self.classes.User,
1836 )
1837
1838 self.mapper_registry.map_imperatively(
1839 User,
1840 users,
1841 properties=dict(
1842 addresses=relationship(
1843 self.mapper_registry.map_imperatively(Address, addresses),
1844 lazy="joined",
1845 )
1846 ),
1847 )
1848
1849 sess = fixture_session()
1850 result = (
1851 sess.query(User)
1852 .order_by(User.id)
1853 .options(sa.orm.lazyload(User.addresses))
1854 ).all()
1855
1856 def go():
1857 eq_(result, self.static.user_address_result)
1858
1859 self.sql_count_(4, go)
1860
1861 def test_option_propagate(self):
1862 users, items, order_items, Order, Item, User, orders = (

Callers

nothing calls this directly

Calls 9

relationshipFunction · 0.90
fixture_sessionFunction · 0.90
map_imperativelyMethod · 0.80
sql_count_Method · 0.80
allMethod · 0.45
optionsMethod · 0.45
order_byMethod · 0.45
queryMethod · 0.45
lazyloadMethod · 0.45

Tested by

no test coverage detected