summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2012-06-16 17:40:15 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2012-06-16 17:40:15 -0400
commit3db5ddfdac37bf4306c11aab5decc1b0aaa90cf8 (patch)
tree2502044bfcccd076014974ccf6056d61e359273e
parent1ac57f0b52e3e89097129931d46ebbbb39ee7927 (diff)
downloadsqlalchemy-3db5ddfdac37bf4306c11aab5decc1b0aaa90cf8.tar.gz
- [bug] Fixed bug whereby populate_existing
option would not propagate to subquery eager loaders. [ticket:2497]. Also in 0.7.8.
-rw-r--r--CHANGES5
-rw-r--r--lib/sqlalchemy/orm/strategies.py2
-rw-r--r--test/orm/test_subquery_relations.py12
3 files changed, 19 insertions, 0 deletions
diff --git a/CHANGES b/CHANGES
index d16ce9777..83be7c483 100644
--- a/CHANGES
+++ b/CHANGES
@@ -202,6 +202,11 @@ CHANGES
[ticket:2454]. Courtesy Jeff Dairiki
also in 0.7.7.
+ - [bug] Fixed bug whereby populate_existing
+ option would not propagate to subquery
+ eager loaders. [ticket:2497]. Also
+ in 0.7.8.
+
- engine
- [bug] Fixed memory leak in C version of
result proxy whereby DBAPIs which don't deliver
diff --git a/lib/sqlalchemy/orm/strategies.py b/lib/sqlalchemy/orm/strategies.py
index 70e06723a..d0f8962be 100644
--- a/lib/sqlalchemy/orm/strategies.py
+++ b/lib/sqlalchemy/orm/strategies.py
@@ -833,6 +833,8 @@ class SubqueryLoader(AbstractRelationshipLoader):
# these will fire relative to subq_path.
q = q._with_current_path(subq_path)
q = q._conditional_options(*orig_query._with_options)
+ if orig_query._populate_existing:
+ q._populate_existing = orig_query._populate_existing
return q
def _setup_outermost_orderby(self, q):
diff --git a/test/orm/test_subquery_relations.py b/test/orm/test_subquery_relations.py
index 70a015f29..90df17609 100644
--- a/test/orm/test_subquery_relations.py
+++ b/test/orm/test_subquery_relations.py
@@ -861,6 +861,18 @@ class LoadOnExistingTest(_fixtures.FixtureTest):
self.assert_sql_count(testing.db, go, 1)
assert 'addresses' not in u1.__dict__
+ def test_populate_existing_propagate(self):
+ User, Address, sess = self._eager_config_fixture()
+ u1 = sess.query(User).get(8)
+ u1.addresses[2].email_address = "foofoo"
+ del u1.addresses[1]
+ u1 = sess.query(User).populate_existing().filter_by(id=8).one()
+ # collection is reverted
+ eq_(len(u1.addresses), 3)
+
+ # attributes on related items reverted
+ eq_(u1.addresses[2].email_address, "ed@lala.com")
+
def test_loads_second_level_collection_to_scalar(self):
User, Address, Dingaling, sess = self._collection_to_scalar_fixture()