Patch is attached again

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

792c792,793
< 
---
>         self._select_state = {}
>         
796,799c797,800
<         if select.limit:
<             s += "TOP %s " % (select.limit,)
<         if select.offset:
<             raise exceptions.InvalidRequestError('MSSQL does not support 
LIMIT with an offset')
---
>         #if select.limit:
>         #    s += "TOP %s " % (select.limit,)
>         #if select.offset:
>         #    raise exceptions.InvalidRequestError('MSSQL does not support 
> LIMIT with an offset')
846a848,883
>               
>         # TODO: put a real copy-container on Select and copy, or somehow make 
> this
>         # not modify the Select statement
>         if self._select_state.get((select, 'visit'), False):
>             # cancel out the compiled order_by on the select
>             if hasattr(select, "order_by_clause"):
>                 self.strings[select.order_by_clause] = ""
>             ansisql.ANSICompiler.visit_select(self, select)
>             return
> 
>         if select.limit is not None or select.offset is not None:
>             self._select_state[(select, 'visit')] = True
>             # to use ROW_NUMBER(), an ORDER BY is required.
>             orderby = self.strings[select.order_by_clause]
>             if not orderby:
>                 orderby = select.oid_column
>                 self.traverse(orderby)
>                 orderby = self.strings[orderby]
>             if not hasattr(select, '_mssql_visit'):
>                 select.append_column(sql.literal_column("ROW_NUMBER() OVER 
> (ORDER BY %s)" % orderby).label("ms_rn"))
>                 select._mssql_visit = True
>             limitselect = sql.select([c for c in select.alias('_mssql').c if 
> c.key!='ms_rn'])
>             
>             if select.offset is not None:
>                 limitselect.append_whereclause("ms_rn > %d" % select.offset)
>                 if select.limit is not None:
>                     limitselect.append_whereclause("ms_rn<=%d" % 
> (select.limit + select.offset))
>             else:
>                 limitselect.append_whereclause("ms_rn<=%d" % select.limit)
>                 
>             self.traverse(limitselect)
>             self.strings[select] = self.strings[limitselect]
>             #print self.strings[select], select.offset, select.limit
>             self.froms[select] = self.froms[limitselect]
>         else:
>             ansisql.ANSICompiler.visit_select(self, select)
848c885
<         super(MSSQLCompiler, self).visit_select(select)
---
>         #super(MSSQLCompiler, self).visit_select(select)

Reply via email to