#9006: QuerySet indexing by __getitem__ gets wrong answer in edge cases
-------------------------------------+--------------------------------------
Reporter: smoluf | Owner: nobody
Status: new | Milestone:
Component: Core framework | Version: 1.0
Resolution: | Keywords: queryset index race
Stage: Unreviewed | Has_patch: 0
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
-------------------------------------+--------------------------------------
Comment (by anonymous):
I encountered the similar problem with my web application. The cause of
error is the unpredictable order of the returned rows.
During {{{__getitem__}}}
calling if the indexed item is absent in the cache, the queryset object
is cloning and building new sql expression with new OFFSET value and LIMIT
1. The builded expression doesn't include ORDER BY part, so in general SQL
backend can return any row.
The best solution that I found is to add
{{{
class Meta:
ordering = ['id']
}}}
to the model definition.
Maybe framework have to do it by default for models without specified
ordering?
--
Ticket URL: <http://code.djangoproject.com/ticket/9006#comment:2>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---