diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2019-04-04 17:32:28 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-04 17:32:28 +0900 |
commit | c9981ae6e022023a46dbab2ace62f7eb256a0816 (patch) | |
tree | 24318e4f244c28480a936d8c76a282faf1b4ac24 /activerecord/test/cases/calculations_test.rb | |
parent | 39d42dbde2571a9a713007c1a8e9f202e004cdeb (diff) | |
parent | 060e09dfb3637b03ef026c5e6b69432c08995c47 (diff) | |
download | rails-c9981ae6e022023a46dbab2ace62f7eb256a0816.tar.gz rails-c9981ae6e022023a46dbab2ace62f7eb256a0816.tar.bz2 rails-c9981ae6e022023a46dbab2ace62f7eb256a0816.zip |
Merge pull request #35850 from kamipo/fix_count_all_with_eager_loading_and_select_and_order
Fix `count(:all)` with eager loading and explicit select and order
Diffstat (limited to 'activerecord/test/cases/calculations_test.rb')
-rw-r--r-- | activerecord/test/cases/calculations_test.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/test/cases/calculations_test.rb b/activerecord/test/cases/calculations_test.rb index f1e35d6ab9..c4070fc341 100644 --- a/activerecord/test/cases/calculations_test.rb +++ b/activerecord/test/cases/calculations_test.rb @@ -243,6 +243,12 @@ class CalculationsTest < ActiveRecord::TestCase assert_queries(1) { assert_equal 11, posts.count(:all) } end + def test_count_with_eager_loading_and_custom_select_and_order + posts = Post.includes(:comments).order("comments.id").select(:type) + assert_queries(1) { assert_equal 11, posts.count } + 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 } |