#31943: restoring pickled query with values() and annotate() creates broken
result
-------------------------------------+-------------------------------------
Reporter: Beda Kosata | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 2.2
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Beda Kosata):
It seems that I have found the culprit. The queryset has an attribute
`_iterable_class`, which in case of a `.objects.all()` type of query is
`ModelIterable`, but when `.values()` is used, it should be
`ValuesIterable`. Unfortunately, this is an attribute of the queryset, not
of the query and thus it does not get pickled and unpickled. If I add
{{{
prices2._iterable_class = ValuesIterable
}}}
after settings `prices2.query`, the result is OK and everything works as
expected.
From my point of view, the solution would be to either add the information
about `_iterable_class` into the pickled query object or at least update
the documentation and inform users they should deal with it themselves.
However, as it is a private attribute, the latter is not a very nice
solution.
--
Ticket URL: <https://code.djangoproject.com/ticket/31943#comment:1>
Django <https://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 unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/064.93c953f59b4b633301cc4da6ccc9d1d5%40djangoproject.com.