From: Mike Bayer Date: Thu, 28 Aug 2008 17:11:18 +0000 (+0000) Subject: - Fixed bug whereby deferred() columns with a group in conjunction X-Git-Tag: rel_0_5rc1~34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=af342bba5600fc312f8efc1d3942301c57ca845f;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - Fixed bug whereby deferred() columns with a group in conjunction with an otherwise unrelated synonym() would produce an AttributeError during deferred load. --- diff --git a/CHANGES b/CHANGES index be0d9aab04..9b163c7c93 100644 --- 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 diff --git a/lib/sqlalchemy/orm/strategies.py b/lib/sqlalchemy/orm/strategies.py index e0166e56ce..f254052ec9 100644 --- a/lib/sqlalchemy/orm/strategies.py +++ b/lib/sqlalchemy/orm/strategies.py @@ -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] diff --git a/test/orm/mapper.py b/test/orm/mapper.py index bcc75e4027..ce47c164a4 100644 --- a/test/orm/mapper.py +++ b/test/orm/mapper.py @@ -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={