aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/calculations_test.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2012-05-16 14:07:10 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2012-05-16 14:07:10 -0700
commit2a38fd58a91a300da5acfe917e82ac681dbd5b50 (patch)
treeb1b66d504e959ef35e61836e054e1bd5ec05fd34 /activerecord/test/cases/calculations_test.rb
parentbf0212b92ab7ebf1f5c6971a1d8ae80e7c18dfb5 (diff)
downloadrails-2a38fd58a91a300da5acfe917e82ac681dbd5b50.tar.gz
rails-2a38fd58a91a300da5acfe917e82ac681dbd5b50.tar.bz2
rails-2a38fd58a91a300da5acfe917e82ac681dbd5b50.zip
MySQL returns "SUM(DISTINCT(credit_limit))" as the column name unless
an alias is provided. Without the alias, the column cannot be found and properly typecast.
Diffstat (limited to 'activerecord/test/cases/calculations_test.rb')
-rw-r--r--activerecord/test/cases/calculations_test.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/activerecord/test/cases/calculations_test.rb b/activerecord/test/cases/calculations_test.rb
index f8bd11e3d0..041f8ffb7c 100644
--- a/activerecord/test/cases/calculations_test.rb
+++ b/activerecord/test/cases/calculations_test.rb
@@ -470,7 +470,11 @@ class CalculationsTest < ActiveRecord::TestCase
assert_equal [50, 53, 55, 60], Account.pluck('DISTINCT credit_limit').sort
assert_equal [50, 53, 55, 60], Account.pluck('DISTINCT accounts.credit_limit').sort
assert_equal [50, 53, 55, 60], Account.pluck('DISTINCT(credit_limit)').sort
- assert_equal [50 + 53 + 55 + 60], Account.pluck('SUM(DISTINCT(credit_limit))')
+
+ # MySQL returns "SUM(DISTINCT(credit_limit))" as the column name unless
+ # an alias is provided. Without the alias, the column cannot be found
+ # and properly typecast.
+ assert_equal [50 + 53 + 55 + 60], Account.pluck('SUM(DISTINCT(credit_limit)) as credit_limit')
end
def test_pluck_expects_a_single_selection