diff options
author | Ernie Miller <ernie@metautonomo.us> | 2011-08-20 13:00:26 -0400 |
---|---|---|
committer | Ernie Miller <ernie@metautonomo.us> | 2011-08-20 13:00:26 -0400 |
commit | e2ae015952c5bdcca044504b5be1c13a518eeaac (patch) | |
tree | e6be33f99ba8e70c723187bc8c05e0490f00c417 /activerecord/test | |
parent | 8bd76aa50ec5dc5da3c398a0fd5dc971f64d8d68 (diff) | |
download | rails-e2ae015952c5bdcca044504b5be1c13a518eeaac.tar.gz rails-e2ae015952c5bdcca044504b5be1c13a518eeaac.tar.bz2 rails-e2ae015952c5bdcca044504b5be1c13a518eeaac.zip |
Fix assumption of primary key name in PredicateBuilder subquery.
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/relations_test.rb | 10 |
1 files changed, 10 insertions, 0 deletions
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) { |