aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/null_relation.rb
diff options
context:
space:
mode:
authorEric Chahin <erc73@cornell.edu>2014-04-16 02:27:26 -0400
committerEric Chahin <erc73@cornell.edu>2014-04-16 09:54:28 -0400
commit93f852569efc4db62e2fed75b2c0bb1866f7065b (patch)
treec8121ad012225fb00dd1ef44ff291583950ff108 /activerecord/lib/active_record/null_relation.rb
parentfe4b0eee05f59831e1468ed50f55fbad0ce11e1d (diff)
downloadrails-93f852569efc4db62e2fed75b2c0bb1866f7065b.tar.gz
rails-93f852569efc4db62e2fed75b2c0bb1866f7065b.tar.bz2
rails-93f852569efc4db62e2fed75b2c0bb1866f7065b.zip
Changed the NullRelation so that when count is called with #group it will properly return an empty hash instead of zero. Fixes issue #14721
Conflicts: activerecord/CHANGELOG.md
Diffstat (limited to 'activerecord/lib/active_record/null_relation.rb')
-rw-r--r--activerecord/lib/active_record/null_relation.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/null_relation.rb b/activerecord/lib/active_record/null_relation.rb
index 5b255c3fe5..05d0c41678 100644
--- a/activerecord/lib/active_record/null_relation.rb
+++ b/activerecord/lib/active_record/null_relation.rb
@@ -43,7 +43,7 @@ module ActiveRecord
end
def count(*)
- 0
+ calculate :count, nil
end
def sum(*)
@@ -54,7 +54,7 @@ module ActiveRecord
# TODO: Remove _options argument as soon we remove support to
# activerecord-deprecated_finders.
if operation == :count
- 0
+ group_values.any? ? Hash.new : 0
else
nil
end