aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2019-07-11 09:09:03 +0900
committerRyuta Kamizono <kamipo@gmail.com>2019-07-11 09:11:01 +0900
commitba7634d304008a4e6170fd701a2b7e75e1d83aea (patch)
tree173a8512d595981e4aca83d75fc4a28490ce0af8 /activerecord/test/cases
parent3fd5bf81c033eb2110533c8a713f38c0245356fb (diff)
parentd9587feb5fab65c4c5bb7a5372f7319f50565f60 (diff)
downloadrails-ba7634d304008a4e6170fd701a2b7e75e1d83aea.tar.gz
rails-ba7634d304008a4e6170fd701a2b7e75e1d83aea.tar.bz2
rails-ba7634d304008a4e6170fd701a2b7e75e1d83aea.zip
Merge pull request #36647 from giraffate/fix_exists_with_distinct_and_offset_and_order_in_postgresql
Fix `relation.exists?` with giving `distinct`, `offset` and `order` for joined table
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/finder_test.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb
index 3752fd42e3..1f2058cc0a 100644
--- a/activerecord/test/cases/finder_test.rb
+++ b/activerecord/test/cases/finder_test.rb
@@ -283,6 +283,11 @@ class FinderTest < ActiveRecord::TestCase
assert_not Post.select(:body).distinct.offset(4).exists?
end
+ def test_exists_with_distinct_and_offset_and_eagerload_and_order
+ assert Post.eager_load(:comments).distinct.offset(10).merge(Comment.order(post_id: :asc)).exists?
+ assert_not Post.eager_load(:comments).distinct.offset(11).merge(Comment.order(post_id: :asc)).exists?
+ end
+
# Ensure +exists?+ runs without an error by excluding distinct value.
# See https://github.com/rails/rails/pull/26981.
def test_exists_with_order_and_distinct