Skip to content

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
@rmosolgo rmosolgo deleted the autoload-docs branch February 20, 2025 20:13
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.

2 participants