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 regression blocking creation of some strict association #48983

Merged

Conversation

JoeDupuis
Copy link
Contributor

@JoeDupuis JoeDupuis commented Aug 19, 2023

#48606 introduced a regression preventing the creation of a chain of models using a has_one through association when strict_loading is activated.

Detail

The association relies on the initial @stale_state being nil to skip loading the target.

#48606 initializes the @stale_state to [nil]

This change converts the [nil] state back to nil while keeping composite primary key support

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Changes that are unrelated should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG N/A

@JoeDupuis JoeDupuis force-pushed the fix-regression-on-strict-has-one-through branch 3 times, most recently from b63345e to 5f62695 Compare August 19, 2023 23:37
PR rails#48606 introduced a regression preventing the creation of a chain
of models using a has_one through association when strict_loading is
activated.

The association relies on the initial stale_state being `nil`
to skip loading the target.
https://github.com/gmcgibbon/rails/blob/755c13f167af4fddc6960ed3768ed7e178a2395a/activerecord/lib/active_record/associations/association.rb#L175

PR rails#48606 initializes the stale_state to `[nil]`
https://github.com/rails/rails/pull/48606/files#diff-39c3da3c5f3fbff01b0a32d3b7ec613fda6bc6225fdbe2629134d91babe37786R84-R86

This change converts the `[nil]` state back to `nil`.
@JoeDupuis JoeDupuis force-pushed the fix-regression-on-strict-has-one-through branch from 5f62695 to 4b35718 Compare August 21, 2023 17:32
@byroot byroot merged commit 5f6c404 into rails:main Aug 22, 2023
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants