aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/relation')
-rw-r--r--activerecord/lib/active_record/relation/finder_methods.rb7
-rw-r--r--activerecord/lib/active_record/relation/merger.rb8
-rw-r--r--activerecord/lib/active_record/relation/query_methods.rb4
3 files changed, 6 insertions, 13 deletions
diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb
index b9e7c52e88..c5562c1ff0 100644
--- a/activerecord/lib/active_record/relation/finder_methods.rb
+++ b/activerecord/lib/active_record/relation/finder_methods.rb
@@ -371,15 +371,14 @@ module ActiveRecord
relation
end
- def construct_join_dependency
- including = eager_load_values + includes_values
+ def construct_join_dependency(associations)
ActiveRecord::Associations::JoinDependency.new(
- klass, table, including
+ klass, table, associations
)
end
def apply_join_dependency(eager_loading: group_values.empty?)
- join_dependency = construct_join_dependency
+ join_dependency = construct_join_dependency(eager_load_values + includes_values)
relation = except(:includes, :eager_load, :preload).joins!(join_dependency)
if eager_loading && !using_limitable_reflections?(join_dependency.reflections)
diff --git a/activerecord/lib/active_record/relation/merger.rb b/activerecord/lib/active_record/relation/merger.rb
index 9cbcf61b3e..10e4779ca4 100644
--- a/activerecord/lib/active_record/relation/merger.rb
+++ b/activerecord/lib/active_record/relation/merger.rb
@@ -120,9 +120,7 @@ module ActiveRecord
joins_dependency = other.joins_values.map do |join|
case join
when Hash, Symbol, Array
- ActiveRecord::Associations::JoinDependency.new(
- other.klass, other.table, join
- )
+ other.send(:construct_join_dependency, join)
else
join
end
@@ -141,9 +139,7 @@ module ActiveRecord
joins_dependency = other.left_outer_joins_values.map do |join|
case join
when Hash, Symbol, Array
- ActiveRecord::Associations::JoinDependency.new(
- other.klass, other.table, join
- )
+ other.send(:construct_join_dependency, join)
else
join
end
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb
index 5b4ba85316..52405f21a1 100644
--- a/activerecord/lib/active_record/relation/query_methods.rb
+++ b/activerecord/lib/active_record/relation/query_methods.rb
@@ -1026,9 +1026,7 @@ module ActiveRecord
join_list = join_nodes + convert_join_strings_to_ast(string_joins)
alias_tracker = alias_tracker(join_list, aliases)
- join_dependency = ActiveRecord::Associations::JoinDependency.new(
- klass, table, association_joins
- )
+ join_dependency = construct_join_dependency(association_joins)
joins = join_dependency.join_constraints(stashed_joins, join_type, alias_tracker)
joins.each { |join| manager.from(join) }