Re: [Sqlalchemy-tickets] [sqlalchemy] #2587: flatten joined-inheritance join targets on individual
Brought to you by:
zzzeek
|
From: sqlalchemy <mi...@zz...> - 2013-05-31 19:09:21
|
#2587: flatten joined-inheritance join targets on individual tables
------------------------------+---------------------------------------
Reporter: zzzeek | Owner: zzzeek
Type: enhancement | Status: new
Priority: medium | Milestone: 0.9.0
Component: orm | Severity: very major - up to 2 days
Resolution: | Keywords:
Progress State: in queue |
------------------------------+---------------------------------------
Comment (by zzzeek):
another thought. push it into the compiler (copied from #2369, applies
more closely here).
{{{
#!sql
# nested join:
SELECT
a.x AS a_x, a.y AS a_y,
b.x AS b_x, b.y AS b_y,
c.x AS c_x, c.y AS c_y
FROM a JOIN (
b JOIN c on b.id=c.id
) on a.id=b.id
# currently, ORM would rewrite this as:
SELECT
a.x AS a_x, a.y AS a_y,
anon_1.b_x AS anon_1_b_x,
anon_1.b_y AS anon_1_b_y,
anon_1.c_x AS anon_1_c_x,
anon_1.c_y AS anon_1_c_y
FROM a JOIN (
SELECT b.id AS b_id, b.x AS b_x, b.y AS b_y, c.x AS c_x,
c.y AS c_y
FROM b JOIN c on b.id=c.id
) AS anon_1 on a.id=anon_1.b_id
# but if we could get compiler to rewrite as:
SELECT
a.x AS a_x, a.y AS a_y,
anon_1.b_x AS b_x,
anon_1.b_y AS b_y,
anon_1.c_x AS c_x,
anon_1.c_y AS c_y
FROM a JOIN (
SELECT b.id AS b_id, b.x AS b_x, b.y AS b_y, c.x AS c_x,
c.y AS c_y
FROM b JOIN c on b.id=c.id
) AS anon_1 on a.id=anon_1.b_id
}}}
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2587#comment:3>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|