]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- the __mapper_args__ dict is copied when propagating to a subclass.
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 23 Feb 2010 00:39:35 +0000 (00:39 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 23 Feb 2010 00:39:35 +0000 (00:39 +0000)
Still need to decide how the argument propagation should
work in the bigger picture.  [ticket:1393]

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

diff --git a/CHANGES b/CHANGES
index a587b3b04bb68f241c52bffcf91d6d431910ad7c..1c29c4787b5c4772770183fb1cc9b9d77d3da55d 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -165,7 +165,11 @@ CHANGES
     (which when using DeclarativeMeta is cls.__dict__).  This should 
     in theory make it easier for custom metaclasses to modify
     the state passed into _as_declarative.
-    
+
+   - the __mapper_args__ dict is copied when propagating to a subclass.
+     Still need to decide how the argument propagation should
+     work in the bigger picture.  [ticket:1393]
+     
 - mysql
   - Fixed reflection bug whereby when COLLATE was present, 
     nullable flag and server defaults would not be reflected.
index d5bd2906b125b7364d46c8ee3d5e9581db0defa7..cc972fc6f74619d19a43d14563367452db2c8494 100644 (file)
@@ -500,7 +500,7 @@ def _as_declarative(cls, classname, dict_):
                     raise exceptions.ArgumentError(
                                 "Can't add additional column %r when specifying __table__" % key)
             
-    mapper_args = getattr(cls, '__mapper_args__', {})
+    mapper_args = dict(getattr(cls, '__mapper_args__', {}))
     if 'inherits' not in mapper_args:
         for c in cls.__bases__:
             if _is_mapped_class(c):
index 9c60e01f3c5e48797c625a5466fb4b02129aeae5..ad99727563d4589226348372efcd802aa1e67a5e 100644 (file)
@@ -918,6 +918,19 @@ class DeclarativeTest(DeclarativeTestBase):
 
 
 class DeclarativeInheritanceTest(DeclarativeTestBase):
+    
+    def test_we_must_copy_mapper_args(self):
+        class Person(Base):
+            __tablename__ = 'people'
+            id = Column(Integer, primary_key=True)
+            discriminator = Column('type', String(50))
+            __mapper_args__ = {'polymorphic_on': discriminator}
+            
+        class Engineer(Person):
+            primary_language = Column(String(50))
+
+        assert 'inherits' not in Person.__mapper_args__
+    
     def test_custom_join_condition(self):
         class Foo(Base):
             __tablename__ = 'foo'