From ff5f328bdfdd3dffd31bd74adac9d1e6e7f241fd Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Thu, 10 Oct 2013 14:50:12 -0700 Subject: delete unused code Now that we merge trees from the top down, we don't need to search through the whole tree for particular nodes, just walk it and merge. --- .../active_record/associations/join_dependency.rb | 40 ---------------------- .../associations/join_dependency/join_part.rb | 10 ------ 2 files changed, 50 deletions(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/associations/join_dependency.rb b/activerecord/lib/active_record/associations/join_dependency.rb index a25a061fc0..31867b6c88 100644 --- a/activerecord/lib/active_record/associations/join_dependency.rb +++ b/activerecord/lib/active_record/associations/join_dependency.rb @@ -61,30 +61,10 @@ module ActiveRecord build tree, @join_root, Arel::InnerJoin end - def graft(associations) - associations.reject { |join_node| - find_node join_node - }.each { |join_node| - parent = find_node(join_node.parent) || join_root - reflection = join_node.reflection - type = join_node.join_type - - next if parent.children.find { |j| j.reflection == reflection } - build_scalar reflection, parent, type - } - self - end - def reflections join_root.drop(1).map!(&:reflection) end - def outer_joins - nodes = join_root.drop 1 - nodes.each { |n| n.join_type = Arel::OuterJoin } - nodes - end - def merge_outer_joins!(other) left = join_root right = other.join_root @@ -148,26 +128,6 @@ module ActiveRecord dup end - def find_node(target_node) - stack = target_node.parents << target_node - - left = [join_root] - right = stack.shift - - loop { - match = left.find { |l| l.match? right } - - if match - return match if stack.empty? - - left = match.children - right = stack.shift - else - return nil - end - } - end - def remove_duplicate_results!(base, records, associations) associations.each do |node| reflection = base.reflect_on_association(node.name) diff --git a/activerecord/lib/active_record/associations/join_dependency/join_part.rb b/activerecord/lib/active_record/associations/join_dependency/join_part.rb index 7175dff5ac..0bd47a3646 100644 --- a/activerecord/lib/active_record/associations/join_dependency/join_part.rb +++ b/activerecord/lib/active_record/associations/join_dependency/join_part.rb @@ -40,16 +40,6 @@ module ActiveRecord self.class == other.class end - def parents - parents = [] - node = parent - while node - parents.unshift node - node = node.parent - end - parents - end - def each(&block) yield self children.each { |child| child.each(&block) } -- cgit v1.2.3