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

 * cc: David Wobrock (added)
 * owner:  nobody => David Wobrock
 * has_patch:  0 => 1
 * status:  new => assigned


Comment:

 Hey all,

 Replying to [comment:6 Mariusz Felisiak]:
 > Replying to [comment:5 Manuel Baclet]:
 > >
 > > With your patch proposal, i do not think that:
 > > `Company.objects.only("name").defer("name").defer("country")` is
 equivalent to `Company.objects.only("name").defer("name", "country")`
 >
 > Did you check this? with proposed patch `country` is the only deferred
 fields in both cases. As far as I'm aware that's an intended behavior.

 I believe Manuel is right. This happens because the set difference in one
 direction gives you the empty set that will clear out the deferred fields
 - but it is missing the fact that we might also be adding more `defer`
 fields than we had `only` fields in the first place, so that we actually
 switch from an `.only()` to a `.defer()` mode.

 See the corresponding PR that should fix this behaviour
 https://github.com/django/django/pull/14667

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

Reply via email to