diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2017-01-15 01:45:51 +0900 |
---|---|---|
committer | Jeremy Daer <jeremydaer@gmail.com> | 2017-02-06 22:41:44 -0700 |
commit | 28977f1fa3d7b15c1608174a165e60b71ddf3995 (patch) | |
tree | 9aab1ec695f9c01b6be74e95b73230946624e893 /activerecord/test/cases/calculations_test.rb | |
parent | 968e66b5df92e5ae88c033dc552e17b4c736874b (diff) | |
download | rails-28977f1fa3d7b15c1608174a165e60b71ddf3995.tar.gz rails-28977f1fa3d7b15c1608174a165e60b71ddf3995.tar.bz2 rails-28977f1fa3d7b15c1608174a165e60b71ddf3995.zip |
Remove useless `column_alias` in `subquery_for_count`
If select clause is specified and last column has a column alias,
additional column alias causes a statement invalid.
Add test coverage for counting a single column with NULL values.
Fixes #27676, #27682, and #27705.
Diffstat (limited to 'activerecord/test/cases/calculations_test.rb')
-rw-r--r-- | activerecord/test/cases/calculations_test.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/activerecord/test/cases/calculations_test.rb b/activerecord/test/cases/calculations_test.rb index b29733a676..0de2fea4c2 100644 --- a/activerecord/test/cases/calculations_test.rb +++ b/activerecord/test/cases/calculations_test.rb @@ -166,14 +166,15 @@ class CalculationsTest < ActiveRecord::TestCase end def test_limit_should_apply_before_count - accounts = Account.limit(3).where("firm_id IS NOT NULL") + accounts = Account.limit(4) assert_equal 3, accounts.count(:firm_id) assert_equal 3, accounts.select(:firm_id).count + assert_equal 3, accounts.select("firm_id firm_id").count end def test_limit_should_apply_before_count_arel_attribute - accounts = Account.limit(3).where("firm_id IS NOT NULL") + accounts = Account.limit(4) firm_id_attribute = Account.arel_table[:firm_id] assert_equal 3, accounts.count(firm_id_attribute) |