Opened 16 years ago
Closed 16 years ago
#7698 closed (fixed)
QuerySet slices broken in corner case: QuerySet[0:0] => QuerySet[0:]
Reported by: | enoksrd | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Keywords: | QuerySet, slice | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
If you have a QuerySet and slice with an upper bound ("end") of 0 it's treated like no upper bound at all. See attached svn diff for a fix. To reproduce: let q be a QuerySet, the q[0:0] is *all* the objects in the set. Problem due to 0 being false in Python.
Attachments (2)
Change History (6)
by , 16 years ago
Attachment: | query.py.diff added |
---|
comment:1 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:2 by , 16 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
This fix appears to be adding extraneous "OFFSET 0" to the ends of non-sliced queries:
sql:
'SELECT [django_session].[session_key], [django_session].[session_data], [django_session].[expire_date] FROM [django_session] WHERE ([django_session].[session_key] = %s AND [django_session].[expire_date] > %s ) OFFSET 0'
comment:3 by , 16 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:4 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
svn diff of my fix against django/db/models/sql/query.py r7602