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

Call eager_load! on loaded dependents, too #5179

Merged
merged 3 commits into from
Dec 2, 2024
Merged

Call eager_load! on loaded dependents, too #5179

merged 3 commits into from
Dec 2, 2024

Conversation

rmosolgo
Copy link
Owner

@rmosolgo rmosolgo commented Dec 2, 2024

Addresses the question in #5178 (comment)

This is inspired Rails's way of handling this is to hard-code dependents that should also be auto-loaded, for example: https://api.rubyonrails.org/classes/ActiveRecord.html#method-c-eager_load-21

# File activerecord/lib/active_record.rb, line 499
def self.eager_load!
  super
  ActiveRecord::Locking.eager_load!
  ActiveRecord::Scoping.eager_load!
  ActiveRecord::Associations.eager_load!
  ActiveRecord::AttributeMethods.eager_load!
  ActiveRecord::ConnectionAdapters.eager_load!
  ActiveRecord::Encryption.eager_load!
end

@rmosolgo rmosolgo added this to the 2.4.5 milestone Dec 2, 2024
@rmosolgo rmosolgo changed the title Add Autoload docs, make it recursive Call eager_load! on loaded dependents, too Dec 2, 2024
@rmosolgo
Copy link
Owner Author

rmosolgo commented Dec 2, 2024

I initially implemented this with recursive eager_load! calls, but given that they're hardcoded now, I'm much less worried about the scope and impact of this change.

@rmosolgo rmosolgo merged commit 797d1e1 into master Dec 2, 2024
13 of 15 checks passed
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.

1 participant