Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto include through associations when 'middle' association was loaded but not modified #145

Conversation

viktorianer
Copy link

When an association goes through another association, e.g. has_many :tags, through: :post_tags, loading the post_tags association was enough, to not auto include the tags association when it is first accessed.
This is correct for when the post_tags association was modified and auto include could lead to weird results. When nothing was modified it is totally fine to auto include the through association.

Code author: Felix Tscheulin https://github.com/Flixt

Backport for #138

…d but not modified (salsify#138)

When an association goes through another association, e.g. `has_many :tags, through: :post_tags`,
loading the `post_tags` association was enough, to not auto include the `tags` association when
it is first accessed.
This is correct for when the `post_tags` association was modified and auto include could lead to
weird results. When nothing was modified it is totally fine to auto include the through association.

Code author: Felix Tscheulin https://github.com/Flixt
@viktorianer viktorianer requested a review from jturkel as a code owner May 30, 2024 19:46
@viktorianer
Copy link
Author

Not sure what happened in #143, but now it should work :D

Copy link
Member

@jturkel jturkel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution. I'll get a release out shortly.

@jturkel jturkel merged commit 1595eb6 into salsify:4-x-stable May 30, 2024
3 checks passed
@jturkel
Copy link
Member

jturkel commented May 30, 2024

@viktorianer - This has been released in 4.2.1.

@viktorianer viktorianer deleted the fix/auto-include-through-associations-when-middle-association-was-loaded branch May 30, 2024 20:35
@viktorianer
Copy link
Author

Thanks a lot, Joel and @Flixt. I could already recheck this, and it works with 4.x too 💯 👍🏼.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants