diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2019-07-08 11:38:34 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-08 11:38:34 +0900 |
commit | 7729dfc6ef0bfddcf55c214b86c7e2530024d58a (patch) | |
tree | f00b34ddd513f0a058d985a80ee159200ed71576 /activerecord/test | |
parent | 930402101c09726ee9d9855cb303f2a8e7d7ab6c (diff) | |
parent | dddb331bd24ab163ac61b4af7abbdb920264bf9b (diff) | |
download | rails-7729dfc6ef0bfddcf55c214b86c7e2530024d58a.tar.gz rails-7729dfc6ef0bfddcf55c214b86c7e2530024d58a.tar.bz2 rails-7729dfc6ef0bfddcf55c214b86c7e2530024d58a.zip |
Merge pull request #36616 from kamipo/dont_use_alias_for_grouped_field
Do not use aliases in GROUP BY clause
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/calculations_test.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/activerecord/test/cases/calculations_test.rb b/activerecord/test/cases/calculations_test.rb index 525085bb28..dbd1d03c4c 100644 --- a/activerecord/test/cases/calculations_test.rb +++ b/activerecord/test/cases/calculations_test.rb @@ -139,6 +139,13 @@ class CalculationsTest < ActiveRecord::TestCase end end + def test_should_not_use_alias_for_grouped_field + assert_sql(/GROUP BY #{Regexp.escape(Account.connection.quote_table_name("accounts.firm_id"))}/i) do + c = Account.group(:firm_id).order("accounts_firm_id").sum(:credit_limit) + assert_equal [1, 2, 6, 9], c.keys.compact + end + end + def test_should_order_by_grouped_field c = Account.group(:firm_id).order("firm_id").sum(:credit_limit) assert_equal [1, 2, 6, 9], c.keys.compact |