On Nov 26, 2007, at 2:25 PM, Paul Johnston wrote:

>
> Hi,
>
> Can someone (Mike?) give me a hand with this, I've hit the limits of  
> my
> understanding of the query compiler.
>
> The patch I've done on #638 (mostly copied from Oracle) creates a
> subquery with row_number if there is an OFFSET. It aliases the query,
> because MSSQL is funny about that, and it also attempts to move  
> ORDER BY
> from the inner to outer query (again, MSSQL is funny). Only problem is
> that it doesn't quite pick up the correct labelled name. Uncomment  
> this
> line in the patch to see the problem:
> #limitselect._order_by_clause = select._order_by_clause
>
> Any ideas would be a help (and a query compiler 101 document would  
> be fab!)
>

attached is a modified version of that patch which includes the unit  
test.  If the SQL isnt right, change the unit tests first to reflect  
what results you'd like to see, then we can try tweaking it.

the key feature used here is the "proxies" element on Column.  this is  
also a new feature, it was previously some nasty methodology before  
0.4.1.

if i have a table:  create table sometable (a int, b int)

and then a select:    select a, b from sometable

and an aliased version of it:    (select a, b from sometable) as anon_1

you've got six columns in play.  you have table.a, table.b; you have  
select.a and select.b, and anon1.a and anon_1.b.  The "proxies"  
collection allows you to navigate from anon_1.a to select.a back to  
table.a; its a collection that in almost all cases has just one  
element (it only has multiple elements when a column is proxying a  
UNION or similar).  So that way you can navigate to the column which  
an aliased column "represents".



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Attachment: mssql.638.patch
Description: Binary data



Reply via email to