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

Method test_load_o2m

test/orm/test_selectin_relations.py:2277–2311  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2275 session.commit()
2276
2277 def test_load_o2m(self):
2278 A, B = self.classes("A", "B")
2279
2280 session = fixture_session()
2281
2282 def go():
2283 q = (
2284 session.query(A)
2285 .options(selectinload(A.bs))
2286 .order_by(A.id1, A.id2)
2287 )
2288 return q.all()
2289
2290 result = self.assert_sql_execution(
2291 testing.db,
2292 go,
2293 CompiledSQL(
2294 "SELECT a.id1 AS a_id1, a.id2 AS a_id2 "
2295 "FROM a ORDER BY a.id1, a.id2",
2296 {},
2297 ),
2298 CompiledSQL(
2299 "SELECT b.a_id1, b.a_id2, b.id "
2300 "FROM b WHERE (b.a_id1, b.a_id2) IN "
2301 "(__[POSTCOMPILE_primary_keys]) ORDER BY b.id",
2302 [{"primary_keys": [(i, i + 2) for i in range(1, 20)]}],
2303 ),
2304 )
2305 eq_(
2306 result,
2307 [
2308 A(id1=i, id2=i + 2, bs=[B(id=(i * 6) + j) for j in range(6)])
2309 for i in range(1, 20)
2310 ],
2311 )
2312
2313 def test_load_m2o(self):
2314 A, B = self.classes("A", "B")

Callers

nothing calls this directly

Calls 6

fixture_sessionFunction · 0.90
CompiledSQLClass · 0.90
eq_Function · 0.90
assert_sql_executionMethod · 0.80
AClass · 0.70
BClass · 0.70

Tested by

no test coverage detected