aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
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/lib/active_record
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/lib/active_record')
-rw-r--r--activerecord/lib/active_record/relation/finder_methods.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb
index 6deb9c7da8..1dbf4808fd 100644
--- a/activerecord/lib/active_record/relation/finder_methods.rb
+++ b/activerecord/lib/active_record/relation/finder_methods.rb
@@ -354,7 +354,7 @@ module ActiveRecord
conditions = sanitize_forbidden_attributes(conditions)
if distinct_value && offset_value
- relation = limit(1)
+ relation = except(:order).limit!(1)
else
relation = except(:select, :distinct, :order)._select!(ONE_AS_ONE).limit!(1)
end