[Django] #29263: Model.refresh_from_db() does not re-calculate annotation fields

12 views
Skip to first unread message

Django

unread,
Mar 26, 2018, 8:32:32 AM3/26/18
to django-...@googlegroups.com
#29263: Model.refresh_from_db() does not re-calculate annotation fields
-----------------------------------------+------------------------
Reporter: Sam Frances | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 2.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
Running refresh_from_db() on a model which was retrieved using an
annotated query, does not update any fields that were added by that
annotated query.

--
Ticket URL: <https://code.djangoproject.com/ticket/29263>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 26, 2018, 9:42:52 AM3/26/18
to django-...@googlegroups.com
#29263: Model.refresh_from_db() does not re-calculate annotation fields
-------------------------------------+-------------------------------------

Reporter: Sam Frances | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: 2.0
(models, ORM) |
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* status: new => closed
* component: Uncategorized => Database layer (models, ORM)
* resolution: => invalid


Comment:

That's
[https://docs.djangoproject.com/en/stable/ref/models/instances/#django.db.models.Model.refresh_from_db
by design]:

Only fields of the model are reloaded from the database. Other database-
dependent values such as annotations aren’t reloaded. Any @cached_property
attributes aren’t cleared either.

--
Ticket URL: <https://code.djangoproject.com/ticket/29263#comment:1>

Reply all
Reply to author
Forward
0 new messages