#32704: QuerySet.defer() doesn't clear deferred field when chaining with only().
-------------------------------------+-------------------------------------
     Reporter:  Manuel Baclet        |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  3.1
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  defer only           |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Manuel Baclet):

 With the proposed patch, I think that:
 {{{#!python
 Company.objects.only("name").defer("name", "country")
 }}}
 loads all fields whereas:
 {{{#!python
 Company.objects.only("name").defer("name").defer("country")
 }}}
 loads all fields except `"country"`.

 Why is that?
 In the first case:
 {{{#!python
 existing.difference(field_names) == {"name"}.difference(["name",
 "country"]) == empty_set
 }}}
 and we go into the `if` branch clearing all the deferred fields and we are
 done.
 In the second case:
 {{{#!python
 existing.difference(field_names) == {"name"}.difference(["name"]) ==
 empty_set
 }}}
 and we go into the `if` branch clearing all the deferred fields. Then we
 add `"country"` to the set of deferred fields.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32704#comment:7>
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.798fef5a30e83ed807e159b886ec83d3%40djangoproject.com.

Reply via email to