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

Support strict_loading on association declarations #38541

merged 1 commit into from Feb 21, 2020


Copy link

kddeisz commented Feb 21, 2020

Raise an error if attempting to load a record from an association that has been marked as strict_loading unless it was explicitly eager loaded.

class Developer < ApplicationRecord
  has_many :projects, strict_loading: true

dev = Developer.first
# => ActiveRecord::StrictLoadingViolationError: The projects association is marked as strict_loading and cannot be lazily loaded.

This is a follow up to the work done on #37400. It effectively allows you to declare that specific relations should always be treated as if the parent were marked in strict mode.

@rails-bot rails-bot bot added the activerecord label Feb 21, 2020
@kddeisz kddeisz requested a review from eileencodes Feb 21, 2020
@eileencodes eileencodes merged commit 3dff30c into rails:master Feb 21, 2020
2 checks passed
2 checks passed
buildkite/rails Build #67138 passed (24 minutes, 29 seconds)

This comment has been minimized.

Copy link

eileencodes commented Feb 21, 2020

Thanks Kevin!

@kddeisz kddeisz deleted the kddeisz:strict-loading-associations branch Feb 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.