#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):

 After reading the documentation carefully, i cannot say that it is clearly
 stated that defering all the fields used in a previous `.only()` call
 performs a reset of the deferred set.

 Moreover, in the `.defer()`
 
[https://docs.djangoproject.com/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.defer
 section], we have:
 > You can make multiple calls to defer(). Each call adds new fields to the
 deferred set:
 and this seems to suggest that:
 - calls to `.defer()` cannot remove items from the deferred set and
 evaluating `qs.defer("some_field")` should never fetch the column
 `"some_field"` (since this should add `"some_field"` to the deferred set)
 - the querysets `qs.defer("field1").defer("field2")` and
 `qs.defer("field1", "field2")` should be equivalent

 IMHO, there is a mismatch between the doc and the actual implementation.

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

Reply via email to