]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Fixed bug whereby deferred() columns with a group in conjunction
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 28 Aug 2008 17:11:18 +0000 (17:11 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 28 Aug 2008 17:11:18 +0000 (17:11 +0000)
with an otherwise unrelated synonym() would produce
an AttributeError during deferred load.

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

diff --git a/CHANGES b/CHANGES
index be0d9aab04ac1e4ddfcdd54ca019ae51c8803ce6..9b163c7c937e02bd0e8a12375ea723e16b60617b 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -39,6 +39,10 @@ CHANGES
     - Fixed primary key update for many-to-many collections where
       the collection had not been loaded yet [ticket:1127]
 
+    - Fixed bug whereby deferred() columns with a group in conjunction
+      with an otherwise unrelated synonym() would produce 
+      an AttributeError during deferred load.
+      
     - The before_flush() hook on SessionExtension takes place before
       the list of new/dirty/deleted is calculated for the final
       time, allowing routines within before_flush() to further
index e0166e56ce1722161b496ba8c5f15e52361a215a..f254052ec921a07c4403db3e82f8e7306e5a2253 100644 (file)
@@ -13,7 +13,7 @@ from sqlalchemy.sql import visitors, expression, operators
 from sqlalchemy.orm import mapper, attributes
 from sqlalchemy.orm.interfaces import (
     LoaderStrategy, StrategizedOption, MapperOption, PropertyOption,
-    serialize_path, deserialize_path
+    serialize_path, deserialize_path, StrategizedProperty
     )
 from sqlalchemy.orm import session as sessionlib
 from sqlalchemy.orm import util as mapperutil
@@ -247,7 +247,13 @@ class LoadDeferredColumns(object):
         if self.keys:
             toload = self.keys
         elif strategy.group:
-            toload = [p.key for p in localparent.iterate_properties if isinstance(p.strategy, DeferredColumnLoader) and p.group==strategy.group]
+            toload = [
+                    p.key for p in 
+                    localparent.iterate_properties 
+                    if isinstance(p, StrategizedProperty) and 
+                      isinstance(p.strategy, DeferredColumnLoader) and 
+                      p.group==strategy.group
+                    ]
         else:
             toload = [self.key]
 
index bcc75e40274a4f5948c3f5f5f952b158197b5469..ce47c164a47ef32d2f5695ab0898ad1ca3303ef4 100644 (file)
@@ -1143,6 +1143,17 @@ class DeferredTest(_fixtures.FixtureTest):
             o.description = "some description"
         self.sql_count_(0, go)
 
+    @testing.resolve_artifact_names
+    def test_synonym_group_bug(self):
+        mapper(Order, orders, properties={
+            'isopen':synonym('_isopen', map_column=True),
+            'description':deferred(orders.c.description, group='foo')
+        })
+        
+        sess = create_session()
+        o1 = sess.query(Order).get(1)
+        eq_(o1.description, "order 1")
+
     @testing.resolve_artifact_names
     def test_unsaved_2(self):
         mapper(Order, orders, properties={