class ConcreteBase(object):
Known subclasses: sqlalchemy.ext.declarative.AbstractConcreteBase
A helper class for 'concrete' declarative mappings.
.ConcreteBase
will use the .polymorphic_union
function automatically, against all tables mapped as a subclass
to this class. The function is called via the
__declare_last__() function, which is essentially
a hook for the .after_configured
event.
.ConcreteBase
produces a mapped
table for the class itself. Compare to .AbstractConcreteBase
,
which does not.
Example:
from sqlalchemy.ext.declarative import ConcreteBase class Employee(ConcreteBase, Base): __tablename__ = 'employee' employee_id = Column(Integer, primary_key=True) name = Column(String(50)) __mapper_args__ = { 'polymorphic_identity':'employee', 'concrete':True} class Manager(Employee): __tablename__ = 'manager' employee_id = Column(Integer, primary_key=True) name = Column(String(50)) manager_data = Column(String(40)) __mapper_args__ = { 'polymorphic_identity':'manager', 'concrete':True}
The name of the discriminator column used by .polymorphic_union
defaults to the name type. To suit the use case of a mapping where an
actual column in a mapped table is already named type, the
discriminator name can be configured by setting the
_concrete_discriminator_name attribute:
class Employee(ConcreteBase, Base): _concrete_discriminator_name = '_concrete_discriminator'
_declarative.ConcreteBase
so that the
virtual discriminator column name can be customized.Class Method | __declare_first__ |
Undocumented |
Class Method | _create_polymorphic_union |
Undocumented |
sqlalchemy.ext.declarative.AbstractConcreteBase
Undocumented