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

Fix association building for belongs_to with :with_deleted option #277

Merged
merged 8 commits into from
Apr 22, 2022

Conversation

mvz
Copy link
Contributor

@mvz mvz commented Apr 9, 2022

The override of belongs_to creates a scope in the association where normally there would be none if the :with_deleted option is given. Having a scope in an association makes ActiveRecord refuse to automatically find an inverse relation. This change adds an override to make an exception if the scope was only added to support the :with_deleted option.

Fixes #232.

@mvz mvz force-pushed the issue-232-fix-association-building branch 2 times, most recently from f80f668 to 5d0858a Compare April 9, 2022 09:55
@mvz mvz force-pushed the issue-232-fix-association-building branch from 5d0858a to 21c2281 Compare April 10, 2022 16:36
mvz added 6 commits April 10, 2022 20:13
…eleted

Normally, ActiveRecord's AssociationReflection does not allow automatic
calculation of the inverse relation if the inverse reflection has a
scope.

This adds an override to AssociationReflection that special-cases
reflections that have a scope that was added _only_ to support the
:with_deleted option.
@mvz mvz force-pushed the issue-232-fix-association-building branch from 98a8041 to 88cc53b Compare April 18, 2022 20:29
@mvz mvz marked this pull request as ready for review April 18, 2022 20:29
@mvz mvz merged commit fdea727 into master Apr 22, 2022
@mvz mvz deleted the issue-232-fix-association-building branch April 22, 2022 15:44
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.

Association building broken with upgrade to 0.7.0
1 participant