diff options
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/calculations_test.rb | 6 |
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 |