On Wednesday, April 6, 2016 at 12:00:22 AM UTC-4, Mike Bayer wrote:
>
> does your test case show that?  I guess I can run it.
>

Thanks.  I think I finally got it. (!)

The confusion stemmed from how the `join()` required the start point on the 
first bit of the "secondary" but not on the latter (e.g. going from 3 
arguments to 2).

- secondary= "join(A2B, C, A2B.b_id == C.b_id)"
- ,primaryjoin="and_(A.id == A2B.a_id)"
- ,secondaryjoin=sqlalchemy.and_(
- C.b_id == sqlalchemy.orm.foreign(A2B.b_id),
+ secondary= "join(A2B, B, A2B.b_id == B.id).join(C, B.id == C.b_id)"
+ ,primaryjoin="and_(A.id == A2B.a_id)"
+ ,secondaryjoin=sqlalchemy.and_(
+ C.b_id == B.id,

The last bit I'm trying to figure out now, is to adding a correlated 
subquery to this (as that helped a lot with another query last week)

I believe the query should look a bit like this: (I joined B, because I 
couldn't find an expression version of orm's `foreign`)

C.id.in_(
sqlalchemy.select([C.id])
.select_from(
C.__table__
.join(B, C.b_id == B.id)
.join(A2B, B.id == A2B.b_id)
)
.where(A2B.a_id == A.id)
.order_by(C.id.desc())
.limit(5)
.correlate()
)

The main issue I've been facing is that sqlite generates an ON issue for 
this 

Otherwise, I've been trying to get it into primaryjoin and secondaryjoin 
with no luck.

I'm just using direct queries now.  This is all just for a spare-time 
project i'm open sourcing so I've only been tackling it at night and during 
lunch.

-- 
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 https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to