On Jan 30, 2008, at 11:08 PM, Michael Bayer wrote:
> > > 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()). like this: Index: lib/sqlalchemy/databases/mssql.py =================================================================== --- lib/sqlalchemy/databases/mssql.py (revision 4108) +++ lib/sqlalchemy/databases/mssql.py (working copy) @@ -896,6 +896,9 @@ else: return None + def visit_select(self, select, within_grouping=False, **kwargs): + return super(MSSQLCompiler, self).visit_select(select, **kwargs) + def visit_table(self, table, mssql_aliased=False, **kwargs): if mssql_aliased: return super(MSSQLCompiler, self).visit_table(table, **kwargs) Index: lib/sqlalchemy/sql/compiler.py =================================================================== --- lib/sqlalchemy/sql/compiler.py (revision 4108) +++ lib/sqlalchemy/sql/compiler.py (working copy) @@ -230,7 +230,7 @@ return "" def visit_grouping(self, grouping, **kwargs): - return "(" + self.process(grouping.elem) + ")" + return "(" + self.process(grouping.elem, within_grouping=True) + ")" def visit_label(self, label, result_map=None): labelname = self._truncated_identifier("colident", label.name) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---