diff options
author | Leonel Galán <leonel@getstealz.com> | 2017-06-16 15:09:15 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-16 15:09:15 -0400 |
commit | 095036467e4e06e56452da94077500d428dd0eed (patch) | |
tree | 3443e6779bf5a1d0f73f3c6ceb5f22cdee12e303 /activerecord/lib/active_record/relation/calculations.rb | |
parent | 0804e58e1e6a52190a950f863622102b6b21ccb8 (diff) | |
parent | b55cf266f9ccadf49276de230a8b0c2076f05202 (diff) | |
download | rails-095036467e4e06e56452da94077500d428dd0eed.tar.gz rails-095036467e4e06e56452da94077500d428dd0eed.tar.bz2 rails-095036467e4e06e56452da94077500d428dd0eed.zip |
Merge branch 'master' into bug/filtered_parameters_class
Diffstat (limited to 'activerecord/lib/active_record/relation/calculations.rb')
-rw-r--r-- | activerecord/lib/active_record/relation/calculations.rb | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/relation/calculations.rb b/activerecord/lib/active_record/relation/calculations.rb index 861b2125d4..c562f214c9 100644 --- a/activerecord/lib/active_record/relation/calculations.rb +++ b/activerecord/lib/active_record/relation/calculations.rb @@ -37,7 +37,16 @@ module ActiveRecord # Note: not all valid {Relation#select}[rdoc-ref:QueryMethods#select] expressions are valid #count expressions. The specifics differ # between databases. In invalid cases, an error from the database is thrown. def count(column_name = nil) - return super() if block_given? + if block_given? + unless column_name.nil? + ActiveSupport::Deprecation.warn \ + "When `count' is called with a block, it ignores other arguments. " \ + "This behavior is now deprecated and will result in an ArgumentError in Rails 5.3." + end + + return super() + end + calculate(:count, column_name) end @@ -73,7 +82,16 @@ module ActiveRecord # # Person.sum(:age) # => 4562 def sum(column_name = nil) - return super() if block_given? + if block_given? + unless column_name.nil? + ActiveSupport::Deprecation.warn \ + "When `sum' is called with a block, it ignores other arguments. " \ + "This behavior is now deprecated and will result in an ArgumentError in Rails 5.3." + end + + return super() + end + calculate(:sum, column_name) end |