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 disabling strict_loading when enabled by default #45018

merged 1 commit into from May 4, 2022


Copy link

@lucthev lucthev commented May 4, 2022


When strict_loading is enabled by default, trying to explicitly disable strict loading at the relation level doesn't work:

class Developer < ApplicationRecord
  self.strict_loading_by_default = true

developer = Developer.strict_loading(false).first
developer.strict_loading? # => true

This PR ensures that .strict_loading(false) results in records which don't strictly load, even when enabled by default.

Other Information

Use-case: in an app with strict loading globally enabled (config.active_record.strict_loading_by_default = true), there's some contexts (noodling around in a Rails console, say) where you want a quick escape hatch.

@eileencodes eileencodes merged commit df1e1bc into rails:main May 4, 2022
4 checks passed
eileencodes added a commit that referenced this issue May 4, 2022
Fix disabling strict_loading when enabled by default
Copy link

@eileencodes eileencodes commented May 4, 2022

Thanks! Congrats on your first PR to Rails 🎉

I've backported this to 7-0-stable in f99f422

@lucthev lucthev deleted the lt/strict-false branch May 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

Successfully merging this pull request may close these issues.

None yet

2 participants