#35950 closed Bug (worksforme)
Fix refreshing of related fields when one field is deferred
Reported by: | Adam Johnson | Owned by: | Adam Johnson |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 5.1 |
Severity: | Normal | Keywords: | |
Cc: | Giannis Terzopoulos | Triage Stage: | Unreviewed |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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.
Change History (3)
comment:1 by , 3 hours ago
Has patch: | set |
---|
comment:2 by , 8 minutes ago
Resolution: | → worksforme |
---|---|
Status: | assigned → closed |
comment:3 by , 3 minutes ago
Cc: | added |
---|
Note:
See TracTickets
for help on using tickets.
I've not been able to replicate following the instructions on Django 5.1.3