I'm having the same problem,
I have a base class called TrackedEntity that has child classes like 
Request and others that inherit from it

on Request I wanted to put a reference to the id of the TrackedEntity that 
created the Request
class Request(TrackedEntity, TrackedEntityContainer, VisibleIdMixin):
     parent_tracked_entity_id = Column(UUID, 
ForeignKey("tracked_entity.id"))

and I get the same error as above.  Adding that inherit condition makes the 
runtime error stop, but it doesn't make sense to me. Why can't I just have 
a foreign key to that table? It's a simple many to one


@Richard: you can use @declared_attr.cascading to cascade the mapper_args 
to your child classes.
On Friday, August 28, 2020 at 2:56:02 PM UTC-4 Richard Damon wrote:

> Thank you, so that go into each subclass that would have the problem.
>
>  8/28/20 2:37 PM, Mike Bayer wrote:
> > the argument you're looking for is inherit_condition:
> >
> > 
> https://docs.sqlalchemy.org/en/13/orm/mapping_api.html#sqlalchemy.orm.mapper.params.inherit_condition
> >
> >
> > class Foo(...):
> >    __mapper_args__ = {
> >       "inherit_condition": node_id == Node.node_id
> >    }
> >
>
> -- 
> Richard Damon
>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/a515b477-5308-4609-af86-c0fb671151cen%40googlegroups.com.

Reply via email to