Re: [sqlalchemy] @declared_attr.cascading doesn't work when inheritance of multiple levels

2021-11-29 Thread Mike Bayer
yeah I am not a huge fan of declared_attr.cascading except for maybe a table name convention On Sun, Nov 28, 2021, at 11:38 PM, niuji...@gmail.com wrote: > Thanks for pointing this out. It did address this problem already. > I just solved this by manually adding all the primary/foreign keys to ea

Re: [sqlalchemy] @declared_attr.cascading doesn't work when inheritance of multiple levels

2021-11-28 Thread niuji...@gmail.com
Thanks for pointing this out. It did address this problem already. I just solved this by manually adding all the primary/foreign keys to each classes. Not a big deal, actually it helps clear code! On Sunday, November 28, 2021 at 6:37:30 PM UTC-8 Mike Bayer wrote: > this is addressed in the docs

Re: [sqlalchemy] @declared_attr.cascading doesn't work when inheritance of multiple levels

2021-11-28 Thread Mike Bayer
this is addressed in the docs which discuss "cascading" here: https://docs.sqlalchemy.org/en/14/orm/declarative_mixins.html#mixing-in-columns-in-inheritance-scenarios "The `declared_attr.cascading` feature currently does *not* allow for a subclass to override the attribute with a different funct

Re: [sqlalchemy] @declared_attr.cascading doesn't work when inheritance of multiple levels

2021-11-28 Thread niuji...@gmail.com
I've just manually put this line to the `Programmer` class definition, but it still gives me the same error, strangely: class Programmer(Engineer): __tablename__ = 'programmer' record_id = Column(ForeignKey('engineer.record_id'), primary_key=True) On Sunda

Re: [sqlalchemy] @declared_attr.cascading doesn't work when inheritance of multiple levels

2021-11-28 Thread Mike Bayer
On Sun, Nov 28, 2021, at 4:24 AM, niuji...@gmail.com wrote: > I'm using the "joined table inheritance" model. I have three levels of > inheritance. > > class has_polymorphic_id(object): > @declared_attr.cascading > def record_id(cls): > if has_inherited_table(cls): >

[sqlalchemy] @declared_attr.cascading doesn't work when inheritance of multiple levels

2021-11-28 Thread niuji...@gmail.com
I'm using the "joined table inheritance" model. I have three levels of inheritance. class has_polymorphic_id(object): @declared_attr.cascading def record_id(cls): if has_inherited_table(cls): return Column(ForeignKey('employee.record_id'), pri