Table is not being created if __abstract__ = False

Issue #3097 resolved
Victor Olex
created an issue
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer

Base = declarative_base()

class A(Base):
    __tablename__ = 'atab'
    id = Column(Integer, primary_key=True)

class B(Base):
    __tablename__ = 'btab'
    __abstract__ = True
    id = Column(Integer, primary_key=True)

class C(Base):
    __tablename__ = 'ctab'
    __abstract__ = False
    id = Column(Integer, primary_key=True)

table_names = Base.metadata.tables.keys()

assert 'atab' in table_names, 'atab not found, this table has not __abstract__ property'
assert 'btab' not in table_names, 'btab found, but this table has __abstract__ = True'
assert 'ctab' in table_names, 'ctab not found, this table has __abstract__ = False'

Comments (6)

  1. Michael Bayer repo owner
    • 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. fixes #3097

    → <<cset 2ad0ddca4c92>>

  2. Log in to comment