diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2019-01-14 22:19:58 -0500 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2019-01-17 16:08:33 -0500 |
commit | 91ddb30083430622188d76eb9f29b78131df67f9 (patch) | |
tree | a92895bf9c2f5e3b344e095e68f448b370af6248 /activerecord/lib | |
parent | 67356f2034ab41305af7218f7c8b2fee2d614129 (diff) | |
download | rails-91ddb30083430622188d76eb9f29b78131df67f9.tar.gz rails-91ddb30083430622188d76eb9f29b78131df67f9.tar.bz2 rails-91ddb30083430622188d76eb9f29b78131df67f9.zip |
Do not allow passing the column name to `sum` when a block is passed
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/relation/calculations.rb | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/relation/calculations.rb b/activerecord/lib/active_record/relation/calculations.rb index 40bae89170..cef31bea94 100644 --- a/activerecord/lib/active_record/relation/calculations.rb +++ b/activerecord/lib/active_record/relation/calculations.rb @@ -84,15 +84,13 @@ module ActiveRecord def sum(column_name = nil) 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 6.0." + raise ArgumentError, "Column name argument is not supported when a block is passed." end - return super() + super() + else + calculate(:sum, column_name) end - - calculate(:sum, column_name) end # This calculates aggregate values in the given column. Methods for #count, #sum, #average, |