Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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.
  • Loading branch information...
commit ff5f328bdfdd3dffd31bd74adac9d1e6e7f241fd 1 parent 223082e
@tenderlove tenderlove authored
View
40 activerecord/lib/active_record/associations/join_dependency.rb
@@ -61,30 +61,10 @@ def initialize(base, associations, joins)
build tree, @join_root, Arel::InnerJoin
end
- def graft(associations)
@radar
radar added a note

We were using this method in Ransack :cry:

Is there an alternative to this now?

@xdite
xdite added a note

+1

@D1plo1d
D1plo1d added a note

This is an issue with Squeel as well :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
- 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 @@ def deep_copy(parent, node)
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)
View
10 activerecord/lib/active_record/associations/join_dependency/join_part.rb
@@ -40,16 +40,6 @@ def match?(other)
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) }
Please sign in to comment.
Something went wrong with that request. Please try again.