using an __abstract__ interferes with declarative determining inherits

Issue #3240 resolved
Mike Bayer repo owner created an issue
from sqlalchemy import Integer, Column, ForeignKey
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()


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__  # passes

assert B2.__mapper__.inherits is A.__mapper__  # fails

Comments (3)

  1. Mike Bayer reporter
    • 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

    → <<cset 95e53d0b6072>>

  2. Log in to comment