mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Extract JoinDependency#join_relation to DRY the repeated application of the #join_associations.
This commit is contained in:
parent
35c198ca9b
commit
fba18f1994
3 changed files with 9 additions and 7 deletions
|
@ -55,6 +55,13 @@ module ActiveRecord
|
||||||
join_parts.first
|
join_parts.first
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def join_relation(relation)
|
||||||
|
join_associations.each do |association|
|
||||||
|
relation = association.join_relation(relation)
|
||||||
|
end
|
||||||
|
relation
|
||||||
|
end
|
||||||
|
|
||||||
def columns
|
def columns
|
||||||
join_parts.collect { |join_part|
|
join_parts.collect { |join_part|
|
||||||
table = join_part.aliased_table
|
table = join_part.aliased_table
|
||||||
|
|
|
@ -225,10 +225,7 @@ module ActiveRecord
|
||||||
|
|
||||||
def apply_join_dependency(relation, join_dependency)
|
def apply_join_dependency(relation, join_dependency)
|
||||||
relation = relation.except(:includes, :eager_load, :preload)
|
relation = relation.except(:includes, :eager_load, :preload)
|
||||||
|
relation = join_dependency.join_relation(relation)
|
||||||
join_dependency.join_associations.each do |association|
|
|
||||||
relation = association.join_relation(relation)
|
|
||||||
end
|
|
||||||
|
|
||||||
if using_limitable_reflections?(join_dependency.reflections)
|
if using_limitable_reflections?(join_dependency.reflections)
|
||||||
relation
|
relation
|
||||||
|
|
|
@ -94,9 +94,7 @@ module ActiveRecord
|
||||||
[])
|
[])
|
||||||
relation.joins! rest
|
relation.joins! rest
|
||||||
|
|
||||||
join_dependency.join_associations.each do |association|
|
@relation = join_dependency.join_relation(relation)
|
||||||
@relation = association.join_relation(relation)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue