Awesome. This was the answer I was really looking for. Thank you.
I'll probably hide the relationship with python for now (I'll look into
association proxies as well) and wait until it's slow enough to bother
anyone before trying to optimize the sql. Trying to use these secondary
composite joins is causing me to lose more hair than it's probably worth.
On Tuesday, March 24, 2015 at 1:12:24 AM UTC-7, Andrew Millspaugh wrote:
>
> I've got a class hierarchy that looks something like this:
>
> [ A ] 1--------* [ B ] 1---------* [ C ] 1----------* [ D ] 1--------0..1
> [ E ] 1..*----------0..1 [ F ]
>
> org proj ticket snap
> bidlimit ticketset
>
> And I'm trying to add a relationship from A to F with a backref. The
> relationship definition (on the A model) looks like:
>
> f = DB.relationship('F',
> secondary=(
> 'join(F, E, F.id == E.f_id)'
> '.join(D, E.d_id == D.id)'
> '.join(C, D.c_id == C.id)'
> '.join(B, C.b_id == B.id)'
> ),
> primaryjoin='A.id == B.a_id',
> secondaryjoin='E.f_id == F.id',
> backref=DB.backref('a', uselist=False), viewonly=True
> )
>
> Now, if I query A.f, I get all of the F's, instead of just the ones which
> have a relationship with A. I'm sure I'm missing something simple, but I
> can't seem to find it... Any help out there?
>
>
--
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 post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.