Hi all
I have a phone table in MySQL which has morphology based on its two
columns, "is_deleted" and "is_active"
If "is_deleted" column is 1, then we don't care about "is_active" column.
If "is_deleted" column is 0, it means that the phone exists and can be
either active or inactive based on "is_active" column
What I have read, looks like this:
class FullPhone(Base):
__tablename__ = 'phone'
is_deleted = Column(TINYINT, nullable=False, server_default='0')
__mapper_args__ = {
'polymorphic_identity': 1,
'polymorphic_on': is_deleted
}
class ExistingPhone(FullPhone):
is_active = Column(TINYINT, server_default='1')
__mapper_args__ = {
'polymorphic_identity': 0,
'polymorphic_on': is_active
}
class ActivePhone(ExistingPhone):
__mapper_args__ = {
'polymorphic_identity': 1,
}
class InactivePhone(ExistingPhone):
__mapper_args__ = {
'polymorphic_identity': 0,
}
When I run this code, I got a warning:
Reassigning polymorphic association for identity 0 from <Mapper at 0x1173f0278
---> to <Mapper at 0x1173f06d8; --->: Check for duplicate use of 0 as value for
polymorphic_identity.
It seems that:
the polymorphic identity '0' of "ExistingPhone" which is a condition on
"is_deleted" column
is mistaken by:
the polymorphic identity '0' of "InactivePhone" which is another condition on
"is_active" column
I appreciate if someone can help me with this structure. Thank you.
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable
Example. See http://stackoverflow.com/help/mcve for a full description.
---
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.