aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/calculations_test.rb
diff options
context:
space:
mode:
authorMax Schwenk <maschwenk@gmail.com>2018-02-25 19:54:20 -0800
committerMax Schwenk <maschwenk@gmail.com>2018-02-25 19:54:20 -0800
commit5120bc90c236d5afed614a80de3431fdd14768dc (patch)
treeb9becc64f682465b8367ab6559110780d9c0d709 /activerecord/test/cases/calculations_test.rb
parent065c1fae12ddfa2b3744d0e872f6b6c10912f2eb (diff)
downloadrails-5120bc90c236d5afed614a80de3431fdd14768dc.tar.gz
rails-5120bc90c236d5afed614a80de3431fdd14768dc.tar.bz2
rails-5120bc90c236d5afed614a80de3431fdd14768dc.zip
Distinct with order #count regression
Diffstat (limited to 'activerecord/test/cases/calculations_test.rb')
-rw-r--r--activerecord/test/cases/calculations_test.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/test/cases/calculations_test.rb b/activerecord/test/cases/calculations_test.rb
index 0828d6b58f..f5971bedfc 100644
--- a/activerecord/test/cases/calculations_test.rb
+++ b/activerecord/test/cases/calculations_test.rb
@@ -242,6 +242,14 @@ class CalculationsTest < ActiveRecord::TestCase
assert_queries(1) { assert_equal 11, posts.count(:all) }
end
+ def test_count_with_eager_loading_and_custom_order_and_distinct
+ posts = Post.includes(:comments).order("comments.id").distinct
+ assert_queries(1) { assert_equal 11, posts.count }
+ assert_queries(1) { assert_equal 11, posts.count(:all) }
+ assert_queries(1) { assert_equal 11, posts.size }
+ assert_queries(1) { assert_equal 11, posts.load.size }
+ end
+
def test_distinct_count_all_with_custom_select_and_order
accounts = Account.distinct.select("credit_limit % 10").order(Arel.sql("credit_limit % 10"))
assert_queries(1) { assert_equal 3, accounts.count(:all) }