Skip to content
Browse files

store references as a string

  • Loading branch information...
1 parent f6cc665 commit a84a20e1cd2133932dd1bd33f862aa2605cc821e @jonleighton jonleighton committed Jan 14, 2012
View
2 activerecord/lib/active_record/relation.rb
@@ -522,7 +522,7 @@ def references_eager_loaded_tables?
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)
View
2 activerecord/lib/active_record/relation/query_methods.rb
@@ -52,7 +52,7 @@ def references(*args)
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
View
4 activerecord/test/cases/relation_test.rb
@@ -140,13 +140,13 @@ def test_references_values
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
View
8 activerecord/test/cases/relations_test.rb
@@ -1178,15 +1178,15 @@ def test_references_doesnt_trigger_eager_loading_if_reference_not_included
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

0 comments on commit a84a20e

Please sign in to comment.
Something went wrong with that request. Please try again.