#34570: QuerySet.defer()  raises an AttributeError when the field is
ManyToManyField or GenericForeignKey
-------------------------------------+-------------------------------------
     Reporter:  Paco Martínez        |                    Owner:  Simon
                                     |  Charette
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  4.2
  (models, ORM)                      |
     Severity:  Release blocker      |               Resolution:  fixed
     Keywords:  contenttypes,        |             Triage Stage:  Ready for
  defer, manytomanyfield,            |  checkin
  genericforeignkey                  |
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Paco Martínez):

 Replying to [comment:2 Simon Charette]:
 > > In version 4.1.9 it is working without any error, but in versions
 4.2.0 and 4.2.1 raises the AttributeError
 >
 > Could you elaborate on that? Many-to-many fields and generic foreign
 keys are not deferrable (they are virtual and do not map to columns) so
 the previous code was simply swallowing invalid values passed to `defer`.
 >
 > I guess that raising a more detailed exception would still require a
 deprecation period and that it would be better to perform this validation
 at `defer`/`only` instead of compilation time anyway so our only option
 here is to silence cases where `opts.get_field(field_name)` returns
 something that doesn't have a `.field` property.

 Well, the more I read about `defer()` and what it was for, the more I
 wondered that we were deferring ''ManyToMany'' and ''GenericForeignKey''
 fields. Thanks for confirming that it was useless and that it just
 swallowed it without taking any action.

 Thank you very much to both of you for your answers and for your quickness
 in solving it.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34570#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/010701882956247c-5490a8a1-0c16-49f1-a057-c840d49821a9-000000%40eu-central-1.amazonses.com.

Reply via email to