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 / >

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,

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?

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 > >

[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 =