aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib')
-rwxr-xr-xactiverecord/lib/active_record/base.rb26
-rw-r--r--activerecord/lib/active_record/calculations.rb2
2 files changed, 7 insertions, 21 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index ab78248608..6b4a1d0071 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -1593,17 +1593,16 @@ module ActiveRecord #:nodoc:
relation
end
- def construct_join(joins, scope)
- merged_joins = scope && scope[:joins] && joins ? merge_joins(scope[:joins], joins) : (joins || scope && scope[:joins])
- case merged_joins
+ def construct_join(joins)
+ case joins
when Symbol, Hash, Array
- if array_of_strings?(merged_joins)
- merged_joins.join(' ') + " "
+ if array_of_strings?(joins)
+ joins.join(' ') + " "
else
- build_association_joins(merged_joins)
+ build_association_joins(joins)
end
when String
- " #{merged_joins} "
+ " #{joins} "
else
""
end
@@ -1614,19 +1613,6 @@ module ActiveRecord #:nodoc:
(Array.wrap(first) + Array.wrap(second)).uniq
end
- def merge_joins(*joins)
- if joins.any?{|j| j.is_a?(String) || array_of_strings?(j) }
- joins = joins.collect do |join|
- join = [join] if join.is_a?(String)
- join = build_association_joins(join) unless array_of_strings?(join)
- join
- end
- joins.flatten.map{|j| j.strip}.uniq
- else
- joins.collect{|j| Array.wrap(j)}.flatten.uniq
- end
- end
-
def build_association_joins(joins)
join_dependency = ActiveRecord::Associations::ClassMethods::JoinDependency.new(self, joins, nil)
relation = active_relation.table
diff --git a/activerecord/lib/active_record/calculations.rb b/activerecord/lib/active_record/calculations.rb
index bbb5922e0e..cd7bd185c5 100644
--- a/activerecord/lib/active_record/calculations.rb
+++ b/activerecord/lib/active_record/calculations.rb
@@ -160,7 +160,7 @@ module ActiveRecord
if includes.any?
merge_with_joins = merge_with_relation ? merge_with_relation.joins_values : []
joins = (merge_with_joins + Array.wrap(options[:joins])).uniq
- join_dependency = ActiveRecord::Associations::ClassMethods::JoinDependency.new(self, includes, construct_join(joins, nil))
+ join_dependency = ActiveRecord::Associations::ClassMethods::JoinDependency.new(self, includes, construct_join(joins))
construct_calculation_arel_with_included_associations(options, join_dependency, merge_with_relation)
else
relation = active_relation.