On Jan 30, 2008, at 10:52 PM, Rick Morrison wrote:

> Thanks Mike,
>
> I've got my local visit_select() a bit munged-up right now with an  
> implementation of OFFSET, so I'm going to wait a bit on this. In the  
> meantime, a follow-up:
>
> Not every MSSQL subquery needs to be aliased, only when the subquery  
> is used as a derived table, as the SA implementation of  
> select.count() does. Is it safe to alias all subqueries (for  
> example, those used by EXISTS & etc.),
>
> or, is there some flag that select.count() sets that the aliasing  
> code could check,
>
> or would it make more sense to have select.count() check a Dialect- 
> specific flag like 'derived_tables_require_alias' and do the  
> aliasing there?

you can in fact alias whatever select you want, i think.   
select.count() doesn't produce any kind of special construct that  
could be detected in the compiler.   there is the notion that  
subqueries which are used as "scalar" subqueries, i.e. for EXISTS, are  
wrapped in a _ScalarSelect wrapper (i.e. select.as_scalar()), but some  
more tracking would have to be added to the compiler to figure out  
that a particular SELECT is wrapped in a scalar (you could also do  
that tracking in the mssql compiler too by overriding visit_grouping()).

>
>
> > also i noticed the usage of a kwarg 'mssql_aliased' which seems to  
> be
> > referenced nowhere.
>
> Looks to me as if the kwarg is being used as a flag to avoid  
> recursion into the visit_table() method. It may not be needed  
> anymore, I'm not up on all the whens and hows of how the visitor  
> pattern threads though all its calls for the Dialects.

yes its referenced there, somehow my text editor missed it earlier.

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to