]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Arguments in __mapper_args__ that aren't "hashable"
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 14 Mar 2011 19:06:53 +0000 (15:06 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 14 Mar 2011 19:06:53 +0000 (15:06 -0400)
aren't mistaken for always-hashable, possibly-column
arguments.  [ticket:2091]

CHANGES
lib/sqlalchemy/ext/declarative.py
test/ext/test_declarative.py

diff --git a/CHANGES b/CHANGES
index 71243e70330f7b34d961f633cc06910acfc9c6e8..c74f4e12bd1e074feb27a921d52a50e5af2b7cd9 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -77,6 +77,10 @@ CHANGES
   - Fix error message referencing old @classproperty
     name to reference @declared_attr [ticket:2061]
 
+  - Arguments in __mapper_args__ that aren't "hashable"
+    aren't mistaken for always-hashable, possibly-column
+    arguments.  [ticket:2091]
+
 0.6.6
 =====
 - orm
index 23905ab415deffcf84d1c4a9fd50e63c79bd87f9..8f5cf5a78c08c54494e3a19bfc5d77dfdd7a68c1 100755 (executable)
@@ -980,9 +980,10 @@ def _as_declarative(cls, classname, dict_):
 
     # make sure that column copies are used rather 
     # than the original columns from any mixins
-    for k, v in mapper_args.iteritems():
-        mapper_args[k] = column_copies.get(v,v)
-
+    for k in ('version_id_col', 'polymorphic_on',):
+        if k in mapper_args:
+            v = mapper_args[k]
+            mapper_args[k] = column_copies.get(v,v)
 
     if classname in cls._decl_class_registry:
         util.warn("The classname %r is already in the registry of this"
@@ -1160,6 +1161,7 @@ def _as_declarative(cls, classname, dict_):
                     # change this ordering when we do [ticket:1892]
                     our_stuff[k] = p.columns + [col]
 
+
     cls.__mapper__ = mapper_cls(cls, 
                                 table, 
                                 properties=our_stuff, 
index 743831d251f6c6d743848c9a1baa98778daa4b28..c552b3a35867634bd5134513db77780df0f9e226 100644 (file)
@@ -1169,7 +1169,28 @@ class DeclarativeInheritanceTest(DeclarativeTestBase):
         assert 'inherits' not in Person.__mapper_args__
         assert class_mapper(Engineer).polymorphic_identity is None
         assert class_mapper(Engineer).polymorphic_on is Person.__table__.c.type
+        
+    def test_we_must_only_copy_column_mapper_args(self):
 
+        class Person(Base):
+
+            __tablename__ = 'people'
+            id = Column(Integer, primary_key=True)
+            a=Column(Integer)
+            b=Column(Integer)
+            c=Column(Integer)
+            d=Column(Integer)
+            discriminator = Column('type', String(50))
+            __mapper_args__ = {'polymorphic_on': discriminator,
+                               'polymorphic_identity': 'person',
+                               'version_id_col': 'a',
+                               'column_prefix': 'bar',
+                               'include_properties': ['id', 'a', 'b'],
+                               }
+        assert class_mapper(Person).version_id_col == 'a'
+        assert class_mapper(Person).include_properties == set(['id', 'a', 'b'])
+        
+        
     def test_custom_join_condition(self):
 
         class Foo(Base):