Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent duplicate records when preloading has_many
When preloading a has_many association, we were simply concatenating the preloaded records without regard to whether they were already loaded on the owner. Even though there is a check for `loaded?` in this part of the preloader, some persisted records may not be marked as such. For example, if a record is created via `owner.association.create`. This change reverts to the previous behavior of replacing the target association while also preserving non-persisted records, which was the goal of #50129. Co-authored-by: John Hawthorn <john@hawthorn.email>
- Loading branch information