Opened 16 years ago
Closed 16 years ago
#10915 closed (duplicate)
For QuerySet qs, list(qs)[k] does not always equal qs[k]
Reported by: | David Gouldin | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.0 |
Severity: | Keywords: | ||
Cc: | dgouldin@…, jdunck@… | Triage Stage: | Unreviewed |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
On QuerySet.__getitem__
(i.e. qs[k]
), a limit/offset is applied to a clone of the queryset. While I think the intent is to retrieve the kth item from the queryset just as it would have been if reached in the process of an iter (in other words, list(qs)[k] == qs[k]
for all k
), the limit/offset method of retrieval is inherently different due to a lack of ordering in the database.
This results in an unstable answer from __getitem__
for models without an order_by
.
Change History (3)
comment:1 by , 16 years ago
Cc: | added |
---|
comment:2 by , 16 years ago
Cc: | added |
---|
comment:3 by , 16 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
#9006 already requested/discussed providing a default ordering for a queryset and was eventually closed wontfix.
#10163 dealt with fixing the formset usage that depended on consistent ordering -- on both trunk and 1.0.X now, an ordering is applied if necessary. This was just fixed in the last day or so. If there are other parts of Django that depend on a consistent ordering, those should be raised as new issues. But changing the base queryset to apply an ordering when the user hasn't specified one isn't likely to happen.
Started a dev list thread here:
http://groups.google.com/group/django-developers/browse_thread/thread/d25e756b373c7017#