From e2ae015952c5bdcca044504b5be1c13a518eeaac Mon Sep 17 00:00:00 2001 From: Ernie Miller Date: Sat, 20 Aug 2011 13:00:26 -0400 Subject: Fix assumption of primary key name in PredicateBuilder subquery. --- activerecord/test/cases/relations_test.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'activerecord/test/cases/relations_test.rb') diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index 97abd67385..711b07b113 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -540,6 +540,16 @@ class RelationTest < ActiveRecord::TestCase } end + def test_find_all_using_where_with_relation_and_alternate_primary_key + cool_first = minivans(:cool_first) + # switching the lines below would succeed in current rails + # assert_queries(2) { + assert_queries(1) { + relation = Minivan.where(:minivan_id => Minivan.where(:name => cool_first.name)) + assert_equal [cool_first], relation.all + } + end + def test_find_all_using_where_with_relation_with_joins david = authors(:david) assert_queries(1) { -- cgit v1.2.3