Hello. > It seems like I have to choose, D can either be a polymorphic child or it can > be > a parent - it can't be both. > > Do I have any options here?
I am almost sure you are correct. This is not possible in SA so you have to flatten your hierarchy. I don't know about experiences with inheritance of others on this list, but mine in SA0.7.9 is not that good. I encountered various limitations along the way. I guess it dependes on the complexity of the queries. We plan to get rid of it eventually in our app. However, if I am not mistaken, SA0.8 addresses all the quirks. Ladislav Lenart On 4.6.2013 07:55, Amir Elaguizy wrote: > Hi there, > > I have a tree that looks like this, reflected via polymorphic inheritance: > > > A > / | \ > B C D > > That works great, like: > > > class BaseModel(db.Model): # Table A in diagram > __tablename__ = "entities" > > id = db.Column(db.BigInteger, primary_key=True, nullable=False, > server_default=func.nextval('guid_seq')) > type_id = db.Column(db.SmallInteger, db.ForeignKey(EntityTypesModel.id)) > > __mapper_args__ = { > 'polymorphic_identity':'entity', > 'polymorphic_on':type_id, > 'with_polymorphic':'*' > } > > class BrandModel(BaseModel): # Table B, C, D in diagram > __tablename__ = 'brands' > > id = db.Column(db.BigInteger, db.ForeignKey(StufffModel.id), > primary_key=True, nullable=False) > name = db.Column(db.String, nullable=False) > > __mapper_args__ = { > 'polymorphic_identity':ET_BRAND, > } > > > The problem is I need to reflect something more like this: > > A > / | \ > B C D > / \ > E F > > Where D is not only a polymorphic child of A but also the polymorphic parents > of > E & F. > > It seems like I have to choose, D can either be a polymorphic child or it can > be > a parent - it can't be both. > > Do I have any options here? > > -- > 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 sqlalchemy+unsubscr...@googlegroups.com. > To post to this group, send email to sqlalchemy@googlegroups.com. > Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. -- 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 sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. For more options, visit https://groups.google.com/groups/opt_out.