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

Remove Preloader#preload #304

Merged
merged 1 commit into from
Jun 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions lib/chrono_model/patches/preloader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,6 @@ def initialize(**options)
end
end

# Patches the AR Preloader (lib/active_record/associations/preloader.rb)
# in order to carry around the +as_of_time+ of the original invocation.
#
# * The +records+ are the parent records where the association is defined
# * The +associations+ are the association names involved in preloading
# * The +given_preload_scope+ is the preloading scope, that is used only
# in the :through association and it holds the intermediate records
# _through_ which the final associated records are eventually fetched.
#
# As the +preload_scope+ is passed around to all the different
# incarnations of the preloader strategies, we are using it to pass
# around the +as_of_time+ of the original query invocation, so that
# preloaded records are preloaded honoring the +as_of_time+.
#
# The +preload_scope+ is present only in through associations, but the
# preloader interfaces expect it to be always defined, for consistency.
#
# For `:through` associations, the +given_preload_scope+ is already a
# +Relation+, that already has the +as_of_time+ getters and setters,
# so we use it directly.
#
def preload(records, associations, given_preload_scope = nil)
super(records, associations, chronomodel_scope(given_preload_scope))
end

private

def chronomodel_scope(given_preload_scope)
Expand Down
Loading