Avoid storing a reference to itself when dealing with create_eager_joins. Also fix a cheating test.
Fixes: #5071
Closes: #5072
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5072
Pull-request-sha:
75ebaf7c91e96d7567eb5760be713dc134c58763
Change-Id: I511ddc0979b46f7928217347199eca4b1d0b4a49
.. change::
:tags: bug, orm, engine
- :tickets: 5056, 5050
+ :tickets: 5056, 5050, 5071
Added test support and repaired a wide variety of unnecessary reference
cycles created for short-lived objects, mostly in the area of ORM queries.
for rec in context.create_eager_joins:
strategy = rec[0]
- strategy(*rec[1:])
+ strategy(context, *rec[1:])
if context.from_clause:
# "load from explicit FROMs" mode,
context.create_eager_joins.append(
(
self._create_eager_join,
- context,
entity,
path,
adapter,
go()
+ def test_query_joinedload(self):
+ User, Address = self.classes("User", "Address")
+
+ s = Session()
+
+ def generate():
+ s.query(User).options(joinedload(User.addresses)).all()
+
+ # cycles here are due to ClauseElement._cloned_set and Load.context
+ @assert_cycles(28)
+ def go():
+ generate()
+
+ go()
+
def test_plain_join(self):
users, addresses = self.tables("users", "addresses")