Re: [Sqlalchemy-tickets] [sqlalchemy] #2746: Add a flag to explicitly enable correlation even when
Brought to you by:
zzzeek
|
From: sqlalchemy <mi...@zz...> - 2013-06-25 21:24:21
|
#2746: Add a flag to explicitly enable correlation even when the subquery has
`asfrom=True`
------------------------------+----------------------------------
Reporter: sayap | Owner: zzzeek
Type: enhancement | Status: new
Priority: highest | Milestone: 0.8.xx
Component: sql | Severity: minor - half an hour
Resolution: | Keywords:
Progress State: needs tests |
------------------------------+----------------------------------
Comment (by zzzeek):
from that change we also can fix correlate_except, which also doesn't do
the right thing here:
{{{
#!python
from sqlalchemy.sql import table, column, select, exists
t1 = table('t1', column('x'))
t2 = table('t2', column('y'))
t3 = table('t3', column('z'))
s = select([t1]).where(t1.c.x == t2.c.y).where(t2.c.y ==
t3.c.z).correlate_except(t1)
print s
}}}
we want:
{{{
SELECT t1.x
FROM t1, t2, t3
WHERE t1.x = t2.y AND t2.y = t3.z
}}}
and not
{{{
SELECT t1.x
FROM t1
WHERE t1.x = t2.y AND t2.y = t3.z
}}}
a similar pattern to the latter is called "backwards correlated" in
test_compiler...but its wrong, and I'd like to be able to add other FROM
clauses to an `any()` or `has()`.
This is getting pretty changy. I don't think there's a real-world use for
"backwards correlated" and correlate_except() is fairly new so hopefully
this is safe for 0.8 still.
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2746#comment:5>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|