diff options
author | Bogdan Gusiev <agresso@gmail.com> | 2014-08-14 13:44:29 +0300 |
---|---|---|
committer | Bogdan Gusiev <agresso@gmail.com> | 2014-08-14 13:44:29 +0300 |
commit | fe67dfbbeea092f0f42e81e4901fe9a949cf9484 (patch) | |
tree | 4749d661e781a38433c2424f3177d0c200f23c35 /activerecord/test/cases/relation | |
parent | 3300fdedc748993b378288c6cbc3113885c955ed (diff) | |
download | rails-fe67dfbbeea092f0f42e81e4901fe9a949cf9484.tar.gz rails-fe67dfbbeea092f0f42e81e4901fe9a949cf9484.tar.bz2 rails-fe67dfbbeea092f0f42e81e4901fe9a949cf9484.zip |
Fixed AR::Relation#where edge case with Hash and other Relation
Example:
Author.where(posts: { author_id: Author.where(country_id: 1) }).joins(:posts)
Diffstat (limited to 'activerecord/test/cases/relation')
-rw-r--r-- | activerecord/test/cases/relation/where_test.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/test/cases/relation/where_test.rb b/activerecord/test/cases/relation/where_test.rb index a6a36a6fd9..b4804aa9d7 100644 --- a/activerecord/test/cases/relation/where_test.rb +++ b/activerecord/test/cases/relation/where_test.rb @@ -61,6 +61,15 @@ module ActiveRecord assert_equal expected.to_sql, actual.to_sql end + def test_belongs_to_nested_where_with_relation + author = authors(:david) + + expected = Author.where(id: author ).joins(:posts) + actual = Author.where(posts: { author_id: Author.where(id: author.id) }).joins(:posts) + + assert_equal expected.to_a, actual.to_a + end + def test_polymorphic_shallow_where treasure = Treasure.new treasure.id = 1 |