Re: [Sqlalchemy-tickets] [sqlalchemy] #2722: clarify what should happen with query(A).select_from(A
Brought to you by:
zzzeek
|
From: sqlalchemy <mi...@zz...> - 2013-05-07 19:30:03
|
#2722: clarify what should happen with query(A).select_from(A).join(B.a)
--------------------------------+-------------------------------
Reporter: rbu | Owner: zzzeek
Type: defect | Status: new
Priority: medium | Milestone: 0.8.xx
Component: documentation | Severity: major - 1-3 hours
Resolution: | Keywords:
Progress State: in queue |
--------------------------------+-------------------------------
Comment (by zzzeek):
yeah I've looked into seeing how an expression like:
{{{
session.query(A).select_from(A).join(B.a)
}}}
could establish the join as "A to B", but this would be an awkward
exception case added to what is otherwise becoming a fairly consistent
system. Using the relationship for the join, "B.a", means "join from B to
A", and that takes precedence here. This works well because "B.a"
contains both the two endpoints, the ON clause, and the direction, i.e.
which side is left and which is right. If Query were to second-guess
this, and look at "select from", that becomes more complicated, in the
case where we are already "selecting from" many things, such as
`query(A).select_from(A).join(A.cs).join(C.bs)` etc. - it means we have to
look at each of "A", "C", and "B" and make a guess which is the best "left
side" to use.
I do sometimes have the case where I don't have a backref set up and would
like to use the reverse side, so I'm wondering if a new symbol like
`session.query(A).join(B.a.reversed)` might be possible.
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2722#comment:5>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|