Is that from django-pyodbc or a very old version of django-mssql?

The recent versions of django-mssql use SELECT ROW_NUMBER() OVER (...) to
avoid some of the issues with flipping the order multiple times. The
biggest issue is that order is not guaranteed without explicitly specifying
the order for all columns.

Regards,
Michael Manfre



On Wed, Jul 31, 2013 at 2:58 PM, Richard Laager <rlaa...@wiktel.com> wrote:

> On Wed, 2013-07-31 at 13:01 +0100, Simon Riggs wrote:
> > 3) retrieve via DESC, apply LIMIT and then re-sort by ASC using derived
> table
> ...
> > (3) would require two sorts on the data like this
> >
> > SELECT * FROM (rest-of-query ORDER BY ... DESC LIMIT n ) ORDER BY ... ASC
>
> I haven't followed this thread closely, but in case this is relevant...
> The MSSQL plugin (at least for old versions of SQL Server) uses*
> something this already. For example, in the following scenario
> (extraneous columns omitted):
>
> In [4]: User.objects.order_by('username')[20:30]
> Out[4]: Executing SQL:
> SELECT *
> FROM (
>   SELECT TOP 10 *
>   FROM (
>     SELECT TOP 30 [users].[id], [users].[username] AS OrdAlias1 FROM
> [users]
>     ORDER BY OrdAlias1 ASC
>   ) AS [users]
>   ORDER BY OrdAlias1 DESC
> ) AS [users]
> ORDER BY OrdAlias1 ASC
>
> * I didn't test the latest version of it or Django.
>
> --
> Richard
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to