Opened 7 years ago

Closed 7 years ago

#28974 closed Cleanup/optimization (fixed)

Model.refresh_from_db() should pass the refreshed instance as a database hint

Reported by: Simon Charette Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

While reviewing the patch for #28918 and reflecting about #28939 I noticed that the refresh_from_db() method was duplicating the work 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.

Change History (2)

comment:1 by Simon Charette, 7 years ago

Has patch: set

comment:2 by Tim Graham <timograham@…>, 7 years ago

Resolution: fixed
Status: newclosed

In f5a989e6:

Fixed #28974 -- Made refresh_from_db() hint routers about its instance.

Note: See TracTickets for help on using tickets.
Back to Top