For QuerySet qs, list(qs)[k] does not always equal qs[k]
|Reported by:||dgouldin||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||1.0|
|Cc:||dgouldin@…, jdunck@…||Triage Stage:||Unreviewed|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
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.