MCPcopy Create free account
hub / github.com/zzzeek/sqlalchemy / test_lazy_options_with_limit

Method test_lazy_options_with_limit

test/orm/test_options.py:1637–1667  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1635 eq_(len(u.addresses), 3)
1636
1637 def test_lazy_options_with_limit(self):
1638 Address, addresses, users, User = (
1639 self.classes.Address,
1640 self.tables.addresses,
1641 self.tables.users,
1642 self.classes.User,
1643 )
1644
1645 self.mapper_registry.map_imperatively(
1646 User,
1647 users,
1648 properties=dict(
1649 addresses=relationship(
1650 self.mapper_registry.map_imperatively(Address, addresses),
1651 lazy="joined",
1652 )
1653 ),
1654 )
1655
1656 sess = fixture_session()
1657 u = (
1658 sess.query(User)
1659 .options(sa.orm.lazyload(User.addresses))
1660 .filter_by(id=8)
1661 ).one()
1662
1663 def go():
1664 eq_(u.id, 8)
1665 eq_(len(u.addresses), 3)
1666
1667 self.sql_count_(1, go)
1668
1669 def test_eager_degrade(self):
1670 """An eager relationship automatically degrades to a lazy relationship

Callers

nothing calls this directly

Calls 9

relationshipFunction · 0.90
fixture_sessionFunction · 0.90
map_imperativelyMethod · 0.80
sql_count_Method · 0.80
oneMethod · 0.45
filter_byMethod · 0.45
optionsMethod · 0.45
queryMethod · 0.45
lazyloadMethod · 0.45

Tested by

no test coverage detected