Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove scope related code from construct_join

  • Loading branch information...
commit 2ee130abec222342c6f7ade3b651840dc89c1bcd 1 parent 8908200
@lifo lifo authored
View
26 activerecord/lib/active_record/base.rb
@@ -1593,17 +1593,16 @@ def construct_finder_arel(options = {}, scope = nil)
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 @@ def merge_includes(first, second)
(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
View
2  activerecord/lib/active_record/calculations.rb
@@ -160,7 +160,7 @@ def construct_calculation_arel(options = {}, merge_with_relation = nil)
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.
Please sign in to comment.
Something went wrong with that request. Please try again.