Browse files

Revert "Merge pull request #5494 from armstrjare/active_record_relati…

…on_keep_association_join_context_on_merge"

This reverts commit dcd04e7, reversing
changes made to 58a4987.
  • Loading branch information...
1 parent dcd04e7 commit 06c787d2359660529ff5b927d3d34f22379eef00 @jonleighton jonleighton committed May 5, 2012
View
2 activerecord/lib/active_record/associations/join_dependency.rb
@@ -109,7 +109,7 @@ def build(associations, parent = nil, join_type = Arel::InnerJoin)
case associations
when Symbol, String
reflection = parent.reflections[associations.to_s.intern] or
- raise ConfigurationError, "Association named '#{ associations }' was not found on #{parent.active_record.name}; perhaps you misspelled it?"
+ raise ConfigurationError, "Association named '#{ associations }' was not found; perhaps you misspelled it?"
unless join_association = find_join_association(reflection, parent)
@reflections << reflection
join_association = build_join_association(reflection, parent)
View
7 activerecord/lib/active_record/associations/join_dependency/join_association.rb
@@ -55,12 +55,7 @@ def ==(other)
def find_parent_in(other_join_dependency)
other_join_dependency.join_parts.detect do |join_part|
- case parent
- when JoinBase
- parent.active_record == join_part.active_record
- else
- parent == join_part
- end
+ parent == join_part
end
end
View
31 activerecord/lib/active_record/relation/merger.rb
@@ -29,25 +29,21 @@ def other
end
class Merger
- attr_reader :relation, :other
+ attr_reader :relation, :values
def initialize(relation, other)
if other.default_scoped? && other.klass != relation.klass
other = other.with_default_scope
end
@relation = relation
- @other = other
- end
-
- def values
- @other.values
+ @values = other.values
end
def normal_values
Relation::SINGLE_VALUE_METHODS +
Relation::MULTI_VALUE_METHODS -
- [:where, :joins, :order, :bind, :reverse_order, :lock, :create_with, :reordering]
+ [:where, :order, :bind, :reverse_order, :lock, :create_with, :reordering]
end
def merge
@@ -58,7 +54,6 @@ def merge
merge_multi_values
merge_single_values
- merge_joins
relation
end
@@ -89,26 +84,6 @@ def merge_single_values
end
end
- def merge_joins
- return if values[:joins].blank?
-
- if other.klass == relation.klass
- relation.joins!(values[:joins])
- else
- joins_to_stash, other_joins = values[:joins].partition { |join|
- case join
- when Hash, Symbol, Array
- true
- else
- false
- end
- }
-
- join_dependency = ActiveRecord::Associations::JoinDependency.new(other.klass, joins_to_stash, [])
- relation.joins!(join_dependency.join_associations + other_joins)
- end
- end
-
def merged_binds
if values[:bind]
(relation.bind_values + values[:bind]).uniq(&:first)
View
9 activerecord/test/cases/relations_test.rb
@@ -6,7 +6,6 @@
require 'models/comment'
require 'models/author'
require 'models/comment'
-require 'models/rating'
require 'models/entrant'
require 'models/developer'
require 'models/reply'
@@ -20,7 +19,7 @@
class RelationTest < ActiveRecord::TestCase
fixtures :authors, :topics, :entrants, :developers, :companies, :developers_projects, :accounts, :categories, :categorizations, :posts, :comments,
- :ratings, :tags, :taggings, :cars, :minivans
+ :tags, :taggings, :cars, :minivans
def test_do_not_double_quote_string_id
van = Minivan.last
@@ -732,12 +731,6 @@ def test_relation_merging_with_joins
assert_equal 1, comments.count
end
- def test_relation_merging_with_merged_joins
- special_comments_with_ratings = SpecialComment.joins(:ratings)
- posts_with_special_comments_with_ratings = Post.group("posts.id").joins(:special_comments).merge(special_comments_with_ratings)
- assert_equal 1, authors(:david).posts.merge(posts_with_special_comments_with_ratings).to_a.length
- end
-
def test_count
posts = Post.scoped

0 comments on commit 06c787d

Please sign in to comment.