diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-08-28 17:11:18 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-08-28 17:11:18 +0000 |
| commit | af342bba5600fc312f8efc1d3942301c57ca845f (patch) | |
| tree | 65bbb2a86a7b36343a2d0b352ecbf44a5b981398 | |
| parent | c99d54e762790578a6c806f6f96da218af2a0f37 (diff) | |
| download | sqlalchemy-af342bba5600fc312f8efc1d3942301c57ca845f.tar.gz | |
- Fixed bug whereby deferred() columns with a group in conjunction
with an otherwise unrelated synonym() would produce
an AttributeError during deferred load.
| -rw-r--r-- | CHANGES | 4 | ||||
| -rw-r--r-- | lib/sqlalchemy/orm/strategies.py | 10 | ||||
| -rw-r--r-- | test/orm/mapper.py | 11 |
3 files changed, 23 insertions, 2 deletions
@@ -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 e0166e56c..f254052ec 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 bcc75e402..ce47c164a 100644 --- a/test/orm/mapper.py +++ b/test/orm/mapper.py @@ -1144,6 +1144,17 @@ class DeferredTest(_fixtures.FixtureTest): 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={ 'description': deferred(orders.c.description)}) |
