#35950: Fix refreshing of related fields when one field is deferred
-------------------------------------+-------------------------------------
               Reporter:  Adam       |          Owner:  Adam Johnson
  Johnson                            |
                   Type:  Bug        |         Status:  assigned
              Component:  Database   |        Version:  5.1
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 In #35044, we fixed the issue where loading a deferred field would clear
 related objects.

 But it left a bug where refreshing all fields explicitly with
 `refresh_from_db()` would no longer clear related objects *if* the model
 instance had any deferred fields.

 This would work on Django 5.0 but is broken on 5.1:

 {{{
 book = Book.objects.defer('title').get(pk=1)
 assert book.author is not None  # fetch related object
 Author.objects.all().delete()

 book.refresh_from_db()
 assert book.author is None  # should have been reset by the refresh
 }}}

 Fix incoming.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35950>
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 visit 
https://groups.google.com/d/msgid/django-updates/0107019372ab473c-b74f1895-6ced-40b9-a97e-490ca255b7d6-000000%40eu-central-1.amazonses.com.

Reply via email to