#28974: Model.refresh_from_db() should pass the refreshed instance as a database
hint
-------------------------------------+-------------------------------------
Reporter: Simon | Owner: nobody
Charette |
Type: | Status: new
Cleanup/optimization |
Component: Database | Version: master
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 |
-------------------------------------+-------------------------------------
While reviewing the patch for #28918 and reflecting about #28939 I noticed
that the `refresh_from_db()` method
[https://github.com/django/django/blob/d065c92678f5d11a70b88e195c6357576eb3a2ef/django/db/models/base.py#L593
was duplicating] the work
[https://github.com/django/django/blob/d065c92678f5d11a70b88e195c6357576eb3a2ef/django/db/utils.py#L261-L263
the routers do] when an `instance` hint is provided.
I figured out that we we're better of using `db_manager(using,
hints={'instance': self})` in this case which would also have the benefit
of passing down `instance` as an hint to possibly defined custom routers.
--
Ticket URL: <https://code.djangoproject.com/ticket/28974>
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/052.222ac13166844dadb91a2364666d6595%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.