MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_deep_options_5

Method test_deep_options_5

test/orm/test_eager_relations.py:6835–6861  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

6833 )
6834
6835 def test_deep_options_5(self):
6836 Item, User, Order = (
6837 self.classes.Item,
6838 self.classes.User,
6839 self.classes.Order,
6840 )
6841
6842 sess = fixture_session()
6843
6844 # joinedload "keywords" on items. it will lazy load "orders", then
6845 # lazy load the "items" on the order, but on "items" it will eager
6846 # load the "keywords"
6847 q3 = (
6848 sess.query(User)
6849 .order_by(User.id)
6850 .options(
6851 sa.orm.defaultload(User.orders)
6852 .defaultload(Order.items)
6853 .joinedload(Item.keywords)
6854 )
6855 )
6856 u = q3.all()
6857
6858 def go():
6859 u[0].orders[1].items[0].keywords[1]
6860
6861 self.sql_count_(2, go)
6862
6863 def test_deep_options_6(self):
6864 Item, User, Order = (

Callers

nothing calls this directly

Calls 8

fixture_sessionFunction · 0.90
joinedloadMethod · 0.80
defaultloadMethod · 0.80
sql_count_Method · 0.80
optionsMethod · 0.45
order_byMethod · 0.45
queryMethod · 0.45
allMethod · 0.45

Tested by

no test coverage detected