Skip to content

Commit

Permalink
remove == so we can see where walking up parents occurs
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Oct 9, 2013
1 parent 217aedf commit 9b15db5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 25 deletions.
25 changes: 15 additions & 10 deletions activerecord/lib/active_record/associations/join_dependency.rb
Expand Up @@ -69,7 +69,7 @@ def graft(*associations)
join_assocs = join_associations

associations.reject { |association|
join_assocs.detect { |a| association == a }
join_assocs.detect { |a| node_cmp association, a }
}.each { |association|
join_node = find_parent_node(association.parent) || @join_root
type = association.join_type
Expand Down Expand Up @@ -122,14 +122,19 @@ def instantiate(result_set)
private

def find_parent_node(parent)
@join_root.find { |join_part|
case parent
when JoinBase
parent.base_klass == join_part.base_klass
else
parent == join_part
end
}
@join_root.find { |join_part| node_cmp parent, join_part }
end

def node_cmp(parent, join_part)
return unless parent.class == join_part.class

case parent
when JoinBase
parent.base_klass == join_part.base_klass
else
parent.reflection == join_part.reflection &&
node_cmp(parent.parent, join_part.parent)
end
end

def join_base
Expand Down Expand Up @@ -182,7 +187,7 @@ def find_or_build_scalar(reflection, parent, join_type)

def find_join_association(reflection, parent)
join_associations.detect { |j|
j.reflection == reflection && j.parent == parent
j.reflection == reflection && node_cmp(j.parent, parent)
}
end

Expand Down
Expand Up @@ -33,12 +33,6 @@ def initialize(reflection, index, parent, join_type, alias_tracker)
def parent_table_name; parent.table_name; end
alias :alias_suffix :parent_table_name

def ==(other)
other.class == self.class &&
other.reflection == reflection &&
other.parent == parent
end

def join_constraints
joins = []
tables = @tables.dup
Expand Down
Expand Up @@ -8,11 +8,6 @@ def initialize(klass)
super(klass, nil)
end

def ==(other)
other.class == self.class &&
other.base_klass == base_klass
end

def aliased_prefix
"t0"
end
Expand Down
Expand Up @@ -48,10 +48,6 @@ def aliased_table
Arel::Nodes::TableAlias.new table, aliased_table_name
end

def ==(other)
raise NotImplementedError
end

# An Arel::Table for the active_record
def table
raise NotImplementedError
Expand Down

0 comments on commit 9b15db5

Please sign in to comment.