Commit Graph

1 Commits

Author SHA1 Message Date
Dmytro Savochkin 781ecc22eb Ensure `reload` sets correct owner for each association
Fix #46363.

Currently calling `reload` re-calculates the association cache based
on the object freshly loaded from the database. The fresh object gets
assigned as `owner` for each association in the association cache.
That object however is not the same as `self` (even though they
both point to the same record). Under some specific circumstances
(using `has_one/has_many through` associations and transactions with
`after_commit` callbacks) this might lead to losing the effects of
assignments done inside the callback.

This commit fixes it by making `reload` point to `self` as `owner`
for each association in the association cache.
2023-11-18 15:59:09 +02:00