diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2016-11-21 05:01:41 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2016-12-05 03:14:06 +0900 |
commit | 22ca710f20c3c656811df006cbf1f4dbc359f7a6 (patch) | |
tree | ae384a39eff456b3643b64707f3896bbe9392fd5 /activerecord/test/cases/relations_test.rb | |
parent | 66076f381aad7383568bf28ae1279b0bc570319c (diff) | |
download | rails-22ca710f20c3c656811df006cbf1f4dbc359f7a6.tar.gz rails-22ca710f20c3c656811df006cbf1f4dbc359f7a6.tar.bz2 rails-22ca710f20c3c656811df006cbf1f4dbc359f7a6.zip |
Fix unscope with subquery
Currently cannot unscope subquery properly.
This commit fixes the issue.
Fixes #26323.
Diffstat (limited to 'activerecord/test/cases/relations_test.rb')
-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 96833ad428..716ace9686 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -1962,6 +1962,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"] |