I have a pretty simple case. A base class with three sub-classes, and then a final class that inherits from the three derived classes. When persisting, sqlalchemy only sets the properties of the parent class and the first child class.
In all other respects the sub-class is behaving properly; it has the correct attributes, etc.
So, if EvidenceLineItem inherits from EvidenceString first, only the string property (and the properties in Evidence) will update; if I change the first inherited class to EvidenceAmount, amount will be persisted, but the rest not.
I'll try declared_attr, but I'm pretty sure that this behaviour isn't what is intended.
~ethan
class Evidence(Base):
__tablename__ = "evidence"
discriminator = Column(DBEnum(ProofItemClassType), nullable=False)
__mapper_args__ = { 'polymorphic_on': discriminator,
'polymorphic_identity': ProofItemClassType.generic }
class EvidenceString(Evidence):
__mapper_args__ = { 'polymorphic_identity': ProofItemClassType.string }
string = Column(String(length=255), index=True)
class EvidenceAmount(Evidence):
__mapper_args__ = { 'polymorphic_identity': ProofItemClassType.amount }
amount = Column(Numeric(precision=7, scale=2), index=True)
class EvidenceQuantity(Evidence):
__mapper_args__ = { 'polymorphic_identity': ProofItemClassType.quantity }
quantity = Column(Integer)
class EvidenceLineItem(EvidenceString, EvidenceAmount, EvidenceQuantity):
__mapper_args__ = { 'polymorphic_identity': ProofItemClassType.line_item }