summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Kirtland <jek@discorporate.us>2007-08-29 20:23:02 +0000
committerJason Kirtland <jek@discorporate.us>2007-08-29 20:23:02 +0000
commitcdde69e7bdef6d9a8a074d1051e099e217d33acf (patch)
tree5153eff88547e83d87c705ad7017e02150874171
parent59ace15998e1e2e5752ba0f86398164af6c2f186 (diff)
downloadsqlalchemy-cdde69e7bdef6d9a8a074d1051e099e217d33acf.tar.gz
Fix for scoped_session's `mapper(extension=<scalar>)` [ticket:760]
-rw-r--r--CHANGES1
-rw-r--r--lib/sqlalchemy/orm/scoping.py2
-rw-r--r--test/orm/session.py12
3 files changed, 14 insertions, 1 deletions
diff --git a/CHANGES b/CHANGES
index 7bf0d8b47..ccd2fdbda 100644
--- a/CHANGES
+++ b/CHANGES
@@ -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)