Re: [sqlalchemy] Relationship Based On Expression

2020-09-09 Thread Bobby Rullo
Wow - thank you so much - that was really above and beyond. There's a lot to digest there so I need to pore it over, but I think I get the general idea. Bobby On Wed, Sep 9, 2020 at 6:10 PM Mike Bayer wrote: > OK what you're trying to do is a little hard , and yes declare_last / > declare_first

Re: [sqlalchemy] Relationship Based On Expression

2020-09-09 Thread Mike Bayer
OK what you're trying to do is a little hard , and yes declare_last / declare_first are useful here, because I just noticed you need to inspect the PK of the local class, not the remote one, so that has to be set up first. So here is a demo based on declare_first, this is the basic idea, eith

Re: [sqlalchemy] Relationship Based On Expression

2020-09-09 Thread Bobby Rullo
Thanks for the reply Mike! I tried to go down the "dynamically add multiple obj_ids" but I could not figure it out. The obvious choice for dynamic stuff is @declared_attr but that only let's me define one thing. How would I do *n* things? Is this a situation where __declare_last__ could help? O

Re: [sqlalchemy] Relationship Based On Expression

2020-09-09 Thread Mike Bayer
On Wed, Sep 9, 2020, at 2:36 PM, Bobby Rullo wrote: > Hi there, > > I'm trying to create a relationship for a Mxin that is agnostic to what the > primary key of the mixed object is. > > Basically we have this: > > class TransitionBase(SurrogatePK, Model): > __abstract__ = True > > o

[sqlalchemy] Relationship Based On Expression

2020-09-09 Thread Bobby Rullo
Hi there, I'm trying to create a relationship for a Mxin that is agnostic to what the primary key of the mixed object is. Basically we have this: class TransitionBase(SurrogatePK, Model): __abstract__ = True obj_id = Column(String, nullable=False, index=True) state = Column(String

Re: [sqlalchemy] ORM AmbiguousForeignKeysErro

2020-09-09 Thread Mark Aquino
It's okay, I misunderstood what to point to in the inherit_condition argument. I pointed it to the right column and it's working now. On Tue, Sep 8, 2020 at 9:37 PM Richard Damon wrote: > On 9/8/20 8:02 PM, Mark Aquino wrote: > > I’m not using that FK for inheritance though. I’m just relating o