diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2017-02-13 01:35:28 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-13 01:35:28 -0300 |
commit | efe121eab01d70c9da5747597d8ac6f526f2da4e (patch) | |
tree | d86d7dc258e24e0831a02fdcf27ecd5a080dea0d /activerecord/test | |
parent | e0d0dc6ec1ea9f690f2f354381c0ddf1c3c2ab0b (diff) | |
parent | bbf1f152644177774710c52a230813e7d06935df (diff) | |
download | rails-efe121eab01d70c9da5747597d8ac6f526f2da4e.tar.gz rails-efe121eab01d70c9da5747597d8ac6f526f2da4e.tar.bz2 rails-efe121eab01d70c9da5747597d8ac6f526f2da4e.zip |
Merge pull request #27122 from kamipo/fix_unscope_with_subquery
Fix unscope with subquery
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/relations_test.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index dc6311e8bc..0c94e891eb 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -1935,6 +1935,18 @@ class RelationTest < ActiveRecord::TestCase assert !Post.all.respond_to?(:by_lifo) end + def test_unscope_with_subquery + p1 = Post.where(id: 1) + p2 = Post.where(id: 2) + + assert_not_equal p1, p2 + + comments = Comment.where(post: p1).unscope(where: :post_id).where(post: p2) + + assert_not_equal p1.first.comments, comments + assert_equal p2.first.comments, comments + end + def test_unscope_removes_binds left = Post.where(id: Arel::Nodes::BindParam.new) column = Post.columns_hash["id"] |