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

Method test_eager_options

test/orm/test_options.py:1576–1607  ·  view source on GitHub ↗

A lazy relationship can be upgraded to an eager relationship.

(self)

Source from the content-addressed store, hash-verified

1574 self.assert_sql_count(testing.db, go, 1)
1575
1576 def test_eager_options(self):
1577 """A lazy relationship can be upgraded to an eager relationship."""
1578
1579 Address, addresses, users, User = (
1580 self.classes.Address,
1581 self.tables.addresses,
1582 self.tables.users,
1583 self.classes.User,
1584 )
1585
1586 self.mapper_registry.map_imperatively(
1587 User,
1588 users,
1589 properties=dict(
1590 addresses=relationship(
1591 self.mapper_registry.map_imperatively(Address, addresses),
1592 order_by=addresses.c.id,
1593 )
1594 ),
1595 )
1596
1597 sess = fixture_session()
1598 result = (
1599 sess.query(User)
1600 .order_by(User.id)
1601 .options(sa.orm.joinedload(User.addresses))
1602 ).all()
1603
1604 def go():
1605 eq_(result, self.static.user_address_result)
1606
1607 self.sql_count_(0, go)
1608
1609 def test_eager_options_with_limit(self):
1610 Address, addresses, users, User = (

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected