Opened 17 years ago
Closed 17 years ago
#5352 closed (fixed)
queryset doesn't honor slicing limits
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Keywords: | qs-rf-fixed | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I noticed this issue today when slicing a query set.
>>> mylist = UserProfile.objects.all()[:20] >>> mylist[20] # Should raise index error <UserProfile: UserProfile object> >>> mylist[2055] <UserProfile: UserProfile object> >>> len(mylist) 20 >>> mylist[20] # Only raises IndexError after I call len() on the queryset Traceback (most recent call last): File "<console>", line 1, in <module> File "/usr/local/lib/python2.5/site-packages/django/db/models/query.py", line 155, in __getitem__ return self._result_cache[k] IndexError: list index out of range
Change History (4)
comment:1 by , 17 years ago
Component: | Uncategorized → Database wrapper |
---|---|
Keywords: | qs-rf added |
Summary: | Initial queryset index is invalid in 0.96 → Initial queryset index is invalid |
Triage Stage: | Unreviewed → Accepted |
Version: | 0.96 → SVN |
comment:2 by , 17 years ago
Summary: | Initial queryset index is invalid → queryset doesn't honor slicing limits |
---|
comment:3 by , 17 years ago
Keywords: | qs-rf-fixed added; qs-rf removed |
---|
The slightly different way we handle __getitem__
in the queryset-refactor branch have fixed this on the branch. The ticket will be closed when the branch is merged.
Note:
See TracTickets
for help on using tickets.
OP mentionned 0.96 but this still happens in trunk.