Hi Wim,
On Wednesday, July 31, 2013 12:04:42 AM UTC+2, Wim Lewis wrote:
>
> On 30 Jul 2013, at 2:06 PM, Florian Apolloner wrote:
> > How do you think such support would look like? For negative indices
> you'd have to know the size of the resultset to be able to do "limit
> somthing offset length-your_negative_index" -- this doesn't seem to make
> any sense for an ORM. You can always do list(qs)]:-1] though…
>
> It seems like the first comment in the ticket answers that question.
> Django would reverse the sense of the query's ordering clause and use a
> simple LIMIT.
>
In my opinion it doesn't; eg imagine the following as query:
MyModel.objects.order_by('whatever')[0:-50]; this isn't translateable into
MyModel.objects.order_by('-whatever')[50:] (the issue here is that the end
is now again undefined) since at least SQLite doesn't support an OFFSET
clause without a LIMIT. Also I think it's more natural to rewrite the
ordering of the query yourself to express that instead of using negative
ranges.
If there isn't an ordering clause in the query, then I agree it makes no
> sense to do any indexing other than [0:N].
>
In that case it's even debatable if limiting makes any sense at all ;)
Cheers,
Florian
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-developers.
For more options, visit https://groups.google.com/groups/opt_out.