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-06 18:11: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: medium | Milestone: 0.9.0
Component: sql | Severity: minor - half an hour
Resolution: | Keywords:
Progress State: in queue |
------------------------------+----------------------------------
Changes (by zzzeek):
* priority: low => medium
* status_field: not decided upon => in queue
* type: task => enhancement
* severity: no triage selected yet => minor - half an hour
* milestone: => 0.9.0
Comment:
well the funny thing here is that we've had a long-standing comment in the
compiler, regarding the fact that the list of "Existing froms" we pass in
is only from the immediate enclosing SELECT, not the SELECT that's
enclosing that one. I think at least we know we can take that out, since
that only applies to auto-correlation and I think we can agree auto-
correlation out of the FROM clause is not necessary. This is the case
where you say, "omit these elements from the FROM clause,
unconditionally".
I'd rather make this specific to each FROM for the "correlate" case.
See the attached patch.
{{{
#!python
t1 = table('t1', column('a'))
t2 = table('t2', column('a'), column('b'))
s = select(
[t2.c.b],
t1.c.a == t2.c.a,
).correlate_except(t2, froms=True).alias('s')
s2 = select([func.foo(s.c.b)]).as_scalar()
s3 = select([t1], order_by=s2)
print s3
}}}
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2746#comment:1>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|