]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Fixed bug introduced in 0.5rc4 involving eager
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 3 Dec 2008 06:23:55 +0000 (06:23 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 3 Dec 2008 06:23:55 +0000 (06:23 +0000)
loading not functioning for properties which were
added to a mapper post-compile using
add_property() or equivalent.

CHANGES
lib/sqlalchemy/orm/mapper.py
test/orm/eager_relations.py

diff --git a/CHANGES b/CHANGES
index 82f770949b4ff90be8e49953cbd49119e2834cde..ca1cf8780383ec5804e3a9a6b48e93b13e8f1025 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -11,6 +11,11 @@ CHANGES
     - Query.select_from(), from_statement() ensure
       that the given argument is a FromClause,
       or Text/Select/Union, respectively.
+      
+    - Fixed bug introduced in 0.5rc4 involving eager 
+      loading not functioning for properties which were
+      added to a mapper post-compile using 
+      add_property() or equivalent.
 
     - Duplicate items in a list-based collection will
       be maintained when issuing INSERTs to
index b5f43b12e96d06c20f03ef028e5b63a9cd7cc746..b48297a6451516c9ecd976e91bda12041d744130 100644 (file)
@@ -860,7 +860,7 @@ class Mapper(object):
         else:
             return mappers, self._selectable_from_mappers(mappers)
 
-    @util.memoized_property
+    @property
     def _default_polymorphic_properties(self):
         return util.unique_list(
             chain(*[list(mapper.iterate_properties) for mapper in [self] + self._with_polymorphic_mappers])
index dc7349b4f4d4118cc79c32662cd4ee8fb19f8f80..94fabd0b11bb17e5a98fcdad982cf3fe7835f0bb 100644 (file)
@@ -23,6 +23,22 @@ class EagerTest(_fixtures.FixtureTest):
         assert [User(id=7, addresses=[Address(id=1, email_address='jack@bean.com')])] == q.filter(User.id==7).all()
         assert self.static.user_address_result == q.all()
 
+    @testing.resolve_artifact_names
+    def test_late_compile(self):
+        m = mapper(User, users)
+        sess = create_session()
+        sess.query(User).all()
+        m.add_property("addresses", relation(mapper(Address, addresses)))
+        
+        sess.clear()
+        def go():
+            eq_(
+               [User(id=7, addresses=[Address(id=1, email_address='jack@bean.com')])],
+               sess.query(User).options(eagerload('addresses')).filter(User.id==7).all()
+            )
+        self.assert_sql_count(testing.db, go, 1)
+            
+        
     @testing.resolve_artifact_names
     def test_no_orphan(self):
         """An eagerly loaded child object is not marked as an orphan"""