diff options
author | Jason Kirtland <jek@discorporate.us> | 2007-08-29 20:23:02 +0000 |
---|---|---|
committer | Jason Kirtland <jek@discorporate.us> | 2007-08-29 20:23:02 +0000 |
commit | cdde69e7bdef6d9a8a074d1051e099e217d33acf (patch) | |
tree | 5153eff88547e83d87c705ad7017e02150874171 | |
parent | 59ace15998e1e2e5752ba0f86398164af6c2f186 (diff) | |
download | sqlalchemy-cdde69e7bdef6d9a8a074d1051e099e217d33acf.tar.gz |
Fix for scoped_session's `mapper(extension=<scalar>)` [ticket:760]
-rw-r--r-- | CHANGES | 1 | ||||
-rw-r--r-- | lib/sqlalchemy/orm/scoping.py | 2 | ||||
-rw-r--r-- | test/orm/session.py | 12 |
3 files changed, 14 insertions, 1 deletions
@@ -17,6 +17,7 @@ CHANGES - [ticket:748] - [ticket:762] + - [ticket:760] 0.4.0beta4 ---------- diff --git a/lib/sqlalchemy/orm/scoping.py b/lib/sqlalchemy/orm/scoping.py index aebcfcdfe..caa46670b 100644 --- a/lib/sqlalchemy/orm/scoping.py +++ b/lib/sqlalchemy/orm/scoping.py @@ -51,7 +51,7 @@ class ScopedSession(object): from sqlalchemy.orm import mapper validate = kwargs.pop('validate', False) - extension = to_list(kwargs.setdefault('extension', [])) + kwargs['extension'] = extension = to_list(kwargs.get('extension', [])) if validate: extension.append(self.extension.validating()) else: diff --git a/test/orm/session.py b/test/orm/session.py index 8c93eacbc..0d0900c3a 100644 --- a/test/orm/session.py +++ b/test/orm/session.py @@ -648,6 +648,18 @@ class ScopedMapperTest(PersistTest): pass Session.mapper(Foo, table2) assert hasattr(Foo, 'query') + + ext = MapperExtension() + + class Bar(object): + pass + Session.mapper(Bar, table2, extension=[ext]) + assert hasattr(Bar, 'query') + + class Baz(object): + pass + Session.mapper(Baz, table2, extension=ext) + assert hasattr(Baz, 'query') def test_validating_constructor(self): s2 = SomeObject(someid=12) |