aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/relations_test.rb
diff options
context:
space:
mode:
authorErnie Miller <ernie@metautonomo.us>2011-08-20 13:00:26 -0400
committerErnie Miller <ernie@metautonomo.us>2011-08-20 13:00:26 -0400
commite2ae015952c5bdcca044504b5be1c13a518eeaac (patch)
treee6be33f99ba8e70c723187bc8c05e0490f00c417 /activerecord/test/cases/relations_test.rb
parent8bd76aa50ec5dc5da3c398a0fd5dc971f64d8d68 (diff)
downloadrails-e2ae015952c5bdcca044504b5be1c13a518eeaac.tar.gz
rails-e2ae015952c5bdcca044504b5be1c13a518eeaac.tar.bz2
rails-e2ae015952c5bdcca044504b5be1c13a518eeaac.zip
Fix assumption of primary key name in PredicateBuilder subquery.
Diffstat (limited to 'activerecord/test/cases/relations_test.rb')
-rw-r--r--activerecord/test/cases/relations_test.rb10
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) {