Skip to content

Table is not being created if __abstract__ = False #3097

@sqlalchemy-bot

Description

@sqlalchemy-bot

Migrated issue, originally created by Victor Olex (@agilevic)

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'

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdeclarativehas to do with the declarative API, scanning classes and mixins for attributes to be mappedlow priority

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions