summaryrefslogtreecommitdiff
path: root/test/ext
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2015-03-10 17:21:46 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2015-03-10 17:21:46 -0400
commit95e53d0b6072510c7a687e3bcc92246d9b3d7181 (patch)
tree6e82dbc97b360f670d7ea81b5000e78637719b4a /test/ext
parenta4a826021fb6d77fadbdac0071616d7e5486e4d1 (diff)
downloadsqlalchemy-95e53d0b6072510c7a687e3bcc92246d9b3d7181.tar.gz
- Fixed bug where using an ``__abstract__`` mixin in the middle
of a declarative inheritance hierarchy would prevent attributes and configuration being correctly propagated from the base class to the inheriting class. fixes #3219 fixes #3240
Diffstat (limited to 'test/ext')
-rw-r--r--test/ext/declarative/test_mixin.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/test/ext/declarative/test_mixin.py b/test/ext/declarative/test_mixin.py
index 6dabfcd22..5cefe8d47 100644
--- a/test/ext/declarative/test_mixin.py
+++ b/test/ext/declarative/test_mixin.py
@@ -1570,3 +1570,44 @@ class AbstractTest(DeclarativeTestBase):
id = Column(Integer, primary_key=True)
eq_(set(Base.metadata.tables), set(['y', 'z', 'q']))
+
+ def test_middle_abstract_attributes(self):
+ # test for [ticket:3219]
+ class A(Base):
+ __tablename__ = 'a'
+
+ id = Column(Integer, primary_key=True)
+ name = Column(String)
+
+ class B(A):
+ __abstract__ = True
+ data = Column(String)
+
+ class C(B):
+ c_value = Column(String)
+
+ eq_(
+ sa.inspect(C).attrs.keys(), ['id', 'name', 'data', 'c_value']
+ )
+
+ def test_middle_abstract_inherits(self):
+ # test for [ticket:3240]
+
+ class A(Base):
+ __tablename__ = 'a'
+ id = Column(Integer, primary_key=True)
+
+ class AAbs(A):
+ __abstract__ = True
+
+ class B1(A):
+ __tablename__ = 'b1'
+ id = Column(ForeignKey('a.id'), primary_key=True)
+
+ class B2(AAbs):
+ __tablename__ = 'b2'
+ id = Column(ForeignKey('a.id'), primary_key=True)
+
+ assert B1.__mapper__.inherits is A.__mapper__
+
+ assert B2.__mapper__.inherits is A.__mapper__