]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Fixed bug when the declarative ``__abstract__`` flag was not being
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 25 Jun 2014 18:30:25 +0000 (14:30 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 25 Jun 2014 18:30:58 +0000 (14:30 -0400)
distinguished for when it was actually the value ``False``.
The ``__abstract__`` flag needs to acutally evaluate to a True
value at the level being tested.
fixes #3097

doc/build/changelog/changelog_09.rst
lib/sqlalchemy/ext/declarative/base.py
test/ext/declarative/test_mixin.py

index 38d71b2ab8bb0cea3dd70b5d86188cb24bd91d4b..691322a8fca70b4804181bbc81a9b594be975733 100644 (file)
     .. include:: changelog_07.rst
         :start-line: 5
 
+.. changelog::
+    :version: 0.9.7
+    :released:
+
+    .. change::
+        :tags: bug, declarative
+        :tickets: 3097
+        :versions: 1.0.0
+
+        Fixed bug when the declarative ``__abstract__`` flag was not being
+        distinguished for when it was actually the value ``False``.
+        The ``__abstract__`` flag needs to acutally evaluate to a True
+        value at the level being tested.
+
 .. changelog::
     :version: 0.9.6
     :released: June 23, 2014
index 0e68faa03df2a207312a7f011e7ae5d94e63a6d3..308c096919a72fccd22f345d8aa01153dc9d0aed 100644 (file)
@@ -56,7 +56,7 @@ def _as_declarative(cls, classname, dict_):
             @event.listens_for(mapper, "before_configured")
             def go():
                 cls.__declare_first__()
-        if '__abstract__' in base.__dict__:
+        if '__abstract__' in base.__dict__ and base.__abstract__:
             if (base is cls or
                 (base in cls.__bases__ and not _is_declarative_inherits)
             ):
index dab627596651d576313acb8d37cdd1676a4e7ce0..d3c2ff9824d7bd2a4f5dd5824821ec1ff95be611 100644 (file)
@@ -115,7 +115,6 @@ class DeclarativeMixinTest(DeclarativeTestBase):
         eq_(MyModelA.__table__.c.foo.type.__class__, String)
         eq_(MyModelB.__table__.c.foo.type.__class__, Integer)
 
-
     def test_not_allowed(self):
 
         class MyMixin:
@@ -1279,3 +1278,27 @@ class DeclarativeMixinPropertyTest(DeclarativeTestBase):
     def test_relationship_primryjoin(self):
         self._test_relationship(True)
 
+
+class AbstractTest(DeclarativeTestBase):
+    def test_abstract_boolean(self):
+
+        class A(Base):
+            __abstract__ = True
+            __tablename__ = 'x'
+            id = Column(Integer, primary_key=True)
+
+        class B(Base):
+            __abstract__ = False
+            __tablename__ = 'y'
+            id = Column(Integer, primary_key=True)
+
+        class C(Base):
+            __abstract__ = False
+            __tablename__ = 'z'
+            id = Column(Integer, primary_key=True)
+
+        class D(Base):
+            __tablename__ = 'q'
+            id = Column(Integer, primary_key=True)
+
+        eq_(set(Base.metadata.tables), set(['y', 'z', 'q']))