MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_late_compile

Method test_late_compile

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

Source from the content-addressed store, hash-verified

252 )
253
254 def test_late_compile(self):
255 User, Address, addresses, users = (
256 self.classes.User,
257 self.classes.Address,
258 self.tables.addresses,
259 self.tables.users,
260 )
261
262 m = self.mapper_registry.map_imperatively(User, users)
263 sess = fixture_session()
264 sess.query(User).all()
265 m.add_property(
266 "addresses",
267 relationship(
268 self.mapper_registry.map_imperatively(Address, addresses)
269 ),
270 )
271
272 sess.expunge_all()
273
274 def go():
275 eq_(
276 [
277 User(
278 id=7,
279 addresses=[
280 Address(id=1, email_address="jack@bean.com")
281 ],
282 )
283 ],
284 sess.query(User)
285 .options(joinedload(User.addresses))
286 .filter(User.id == 7)
287 .all(),
288 )
289
290 self.assert_sql_count(testing.db, go, 1)
291
292 def test_no_orphan(self):
293 """An eagerly loaded child object is not marked as an orphan"""

Callers

nothing calls this directly

Calls 8

fixture_sessionFunction · 0.90
relationshipFunction · 0.90
map_imperativelyMethod · 0.80
add_propertyMethod · 0.80
assert_sql_countMethod · 0.80
allMethod · 0.45
queryMethod · 0.45
expunge_allMethod · 0.45

Tested by

no test coverage detected