diff options
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/relation.rb | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/relation/query_methods.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/relation_test.rb | 4 | ||||
-rw-r--r-- | activerecord/test/cases/relations_test.rb | 8 |
4 files changed, 8 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index dcfce448b1..7838271e5c 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -522,7 +522,7 @@ module ActiveRecord joined_tables = joined_tables.flatten.compact.map { |t| t.downcase }.uniq (tables_in_string(to_sql) - joined_tables).any? || - (includes_values & references_values).any? + (references_values - joined_tables).any? end def tables_in_string(string) diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index ef3545c76a..75369513e3 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -52,7 +52,7 @@ module ActiveRecord return self if args.blank? relation = clone - relation.references_values = (references_values + args).flatten.uniq + relation.references_values = (references_values + args.flatten.map(&:to_s)).uniq relation end diff --git a/activerecord/test/cases/relation_test.rb b/activerecord/test/cases/relation_test.rb index 5a6a3b81de..b93a719687 100644 --- a/activerecord/test/cases/relation_test.rb +++ b/activerecord/test/cases/relation_test.rb @@ -140,13 +140,13 @@ module ActiveRecord relation = Relation.new :a, :b assert_equal [], relation.references_values relation = relation.references(:foo).references(:omg, :lol) - assert_equal [:foo, :omg, :lol], relation.references_values + assert_equal ['foo', 'omg', 'lol'], relation.references_values end def test_references_values_dont_duplicate relation = Relation.new :a, :b relation = relation.references(:foo).references(:foo) - assert_equal [:foo], relation.references_values + assert_equal ['foo'], relation.references_values end end end diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index a652a52f38..d8599b1e6d 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -1178,15 +1178,15 @@ class RelationTest < ActiveRecord::TestCase def test_automatically_added_references scope = Post.where(:comments => { :body => "Bla" }) - assert_equal [:comments], scope.references_values + assert_equal ['comments'], scope.references_values scope = Post.where('comments.body' => 'Bla') - assert_equal [:comments], scope.references_values + assert_equal ['comments'], scope.references_values scope = Post.having(:comments => { :body => "Bla" }) - assert_equal [:comments], scope.references_values + assert_equal ['comments'], scope.references_values scope = Post.having('comments.body' => 'Bla') - assert_equal [:comments], scope.references_values + assert_equal ['comments'], scope.references_values end end |