#31943: Queryset with values()/values_list() crashes when recreated from a 
pickled
query.
-------------------------------------+-------------------------------------
     Reporter:  Beda Kosata          |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  2.2
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by felixxm):

 * stage:  Unreviewed => Accepted


Comment:

 Thanks for this ticket, I was able to reproduce this issue. We could set
 `_iterable_class` when `query.values_select` is not empty:
 {{{
 diff --git a/django/db/models/query.py b/django/db/models/query.py
 index b48d0df9c0..85cd8311a7 100644
 --- a/django/db/models/query.py
 +++ b/django/db/models/query.py
 @@ -210,6 +210,8 @@ class QuerySet:

      @query.setter
      def query(self, value):
 +        if value.values_select:
 +            self._iterable_class = ValuesIterable
          self._query = value

      def as_manager(cls):
 }}}

 however this will not respect `values_list()` with different classes
 (`NamedValuesListIterable`, `FlatValuesListIterable`,
 `ValuesListIterable`). This may not be feasible, we can add a note about
 this restriction to docs.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31943#comment:2>
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.c0d1131c72a4d995429b55c7ca96b63e%40djangoproject.com.

Reply via email to