diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-05-14 07:21:30 -0700 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-05-14 07:21:30 -0700 |
commit | 5b020fa1101b878e5f3b8b8a5e7d47e39b505b1e (patch) | |
tree | 4dcbee09d374aa64614da8ad9b5f4e81465b71e1 /activerecord/test | |
parent | 010ea715f2a629059117054f8079a5a1f60f30f6 (diff) | |
parent | 23c656c1bc113e5f198464ad29d72c5238bfd796 (diff) | |
download | rails-5b020fa1101b878e5f3b8b8a5e7d47e39b505b1e.tar.gz rails-5b020fa1101b878e5f3b8b8a5e7d47e39b505b1e.tar.bz2 rails-5b020fa1101b878e5f3b8b8a5e7d47e39b505b1e.zip |
Merge pull request #10616 from Empact/backport-distinct-distinct
Backport a super-simplified version of #6792, fixing that #exists? can produce invalid SQL: "SELECT DISTINCT DISTINCT"
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/finder_test.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb index 21bd7b51d5..2efafe5c24 100644 --- a/activerecord/test/cases/finder_test.rb +++ b/activerecord/test/cases/finder_test.rb @@ -93,6 +93,18 @@ class FinderTest < ActiveRecord::TestCase assert !Topic.includes(:replies).limit(1).where('0 = 1').exists? end + def test_exists_with_distinct_association_includes_and_limit + author = Author.first + assert !author.unique_categorized_posts.includes(:special_comments).limit(0).exists? + assert author.unique_categorized_posts.includes(:special_comments).limit(1).exists? + end + + def test_exists_with_distinct_association_includes_limit_and_order + author = Author.first + assert !author.unique_categorized_posts.includes(:special_comments).order('comments.taggings_count DESC').limit(0).exists? + assert author.unique_categorized_posts.includes(:special_comments).order('comments.taggings_count DESC').limit(1).exists? + end + def test_exists_with_empty_table_and_no_args_given Topic.delete_all assert !Topic.exists? |