Changes between Initial Version and Version 1 of Ticket #35376, comment 3
- Timestamp:
- Apr 15, 2024, 1:24:08 PM (7 months ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #35376, comment 3
initial v1 3 3 What is happening here is that in the third case `restaurant` is prefetched and stored on the instance but then accessing `city_id` to prefetch the right `city` requires calling `refresh_from_db` (as it's excluded from the select mask) then #35044 (which clears all prefetched data on each `refresh_from_db` call) is triggered and the prefetched `restaurant` instance is discarded causing the access to the property in the test to refetch from the database. 4 4 5 It works in the second case because the whole deferred `city_id` query retrieval happens before the `restaurant` caching happens to the `refresh_from_db(fieds=["city_id"])` cache clear has to effect. 6 ` 5 7 The only solution in 4.2 is to include `city` in your select mask (like you'd want to do anyway to avoid a N+1) to avoid the bugged `refresh_from_db` call.