MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_eager_options

Method test_eager_options

test/orm/test_options.py:1566–1597  ·  view source on GitHub ↗

A lazy relationship can be upgraded to an eager relationship.

(self)

Source from the content-addressed store, hash-verified

1564 self.assert_sql_count(testing.db, go, 1)
1565
1566 def test_eager_options(self):
1567 """A lazy relationship can be upgraded to an eager relationship."""
1568
1569 Address, addresses, users, User = (
1570 self.classes.Address,
1571 self.tables.addresses,
1572 self.tables.users,
1573 self.classes.User,
1574 )
1575
1576 self.mapper_registry.map_imperatively(
1577 User,
1578 users,
1579 properties=dict(
1580 addresses=relationship(
1581 self.mapper_registry.map_imperatively(Address, addresses),
1582 order_by=addresses.c.id,
1583 )
1584 ),
1585 )
1586
1587 sess = fixture_session()
1588 result = (
1589 sess.query(User)
1590 .order_by(User.id)
1591 .options(sa.orm.joinedload(User.addresses))
1592 ).all()
1593
1594 def go():
1595 eq_(result, self.static.user_address_result)
1596
1597 self.sql_count_(0, go)
1598
1599 def test_eager_options_with_limit(self):
1600 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