aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/calculations_test.rb
diff options
context:
space:
mode:
authorLauro Caetano <laurocaetano1@gmail.com>2014-04-07 11:07:46 -0300
committerLauro Caetano <laurocaetano1@gmail.com>2014-04-07 11:15:30 -0300
commitbbad7523f08936f38938c7d4ff18f4084f008244 (patch)
tree56cc99b5d5258baf0b070344d3de386de2cf6695 /activerecord/test/cases/calculations_test.rb
parent013b7c19c81b95583cb537fd2b4330f6860c8502 (diff)
downloadrails-bbad7523f08936f38938c7d4ff18f4084f008244.tar.gz
rails-bbad7523f08936f38938c7d4ff18f4084f008244.tar.bz2
rails-bbad7523f08936f38938c7d4ff18f4084f008244.zip
Ignore order when doing count.
This is necessary because Postgresql doesn't play nice with ORDER BY and no GROUP BY. Fixes #14621.
Diffstat (limited to 'activerecord/test/cases/calculations_test.rb')
-rw-r--r--activerecord/test/cases/calculations_test.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/activerecord/test/cases/calculations_test.rb b/activerecord/test/cases/calculations_test.rb
index db999f90ab..b8de78934e 100644
--- a/activerecord/test/cases/calculations_test.rb
+++ b/activerecord/test/cases/calculations_test.rb
@@ -387,6 +387,20 @@ class CalculationsTest < ActiveRecord::TestCase
assert_raise(ArgumentError) { Account.count(1, 2, 3) }
end
+ def test_count_with_order
+ assert_equal 6, Account.order(:credit_limit).count
+ end
+
+ def test_count_with_reverse_order
+ assert_equal 6, Account.order(:credit_limit).reverse_order.count
+ end
+
+ def test_count_with_where_and_order
+ assert_equal 1, Account.where(firm_name: '37signals').count
+ assert_equal 1, Account.where(firm_name: '37signals').order(:firm_name).count
+ assert_equal 1, Account.where(firm_name: '37signals').order(:firm_name).reverse_order.count
+ end
+
def test_should_sum_expression
# Oracle adapter returns floating point value 636.0 after SUM
if current_adapter?(:OracleAdapter)