Opened 3 years ago

Closed 3 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: master
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


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 Changed 3 years ago by Simon Charette

Has patch: set

comment:2 Changed 3 years ago by Tim Graham <timograham@…>

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