uhm, aside from calculating the offset with lmin+1, I understand the effort 
on supporting this but ..... I explained why row_number is not a viable 
option:
- orderby and limitby together will not play nice (ever :-P) 
and with this implementation:
- you can't have an ORDER BY clause inside the subselect (select * from 
(select * from auth_user order by first_name desc) TMP  will raise an error)
- any table without the "id" field will go into exception (primary_key=[] 
and Field('otherid', 'id') support ?)
- groupby and distinct won't work with limitby

Sure we want to go that way ?

On Wednesday, December 5, 2012 1:30:05 AM UTC+1, Massimo Di Pierro wrote:
>
> OK. This is similar to how Oracle handles it too. How about this?
>
> class MSSQL3Adapter(MSSQLAdapter):
>     def select_limitby(self, sql_s, sql_f, sql_t, sql_w, sql_o, limitby):
>         if limitby:
>             (lmin, lmax) = limitby
>             return 'SELECT %s FROM (SELECT %s ROW_NUMBER() over (order by 
> id) AS w_row, %s FROM %s%s%s) TMP WHERE w_row BETWEEN %i AND %s;' % 
> (sql_f,sql_s,sql_f,sql_t,sql_w,sql_o,lmin,lmax)
>         return 'SELECT %s %s FROM %s%s%s;' % 
> (sql_s,sql_f,sql_t,sql_w,sql_o)
>     def rowslice(self,rows,minimum=0,maximum=None):
>         return rows
>
> Can you help test it?
>

-- 



Reply via email to