From 929c2261cdb279d6184cc288d7ab014c1414799c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Wed, 11 Dec 2013 13:35:34 -0200 Subject: Mark the arguments needed by activerecord-deprecated_finders with a TODO --- .../lib/active_record/associations/collection_association.rb | 2 ++ .../lib/active_record/associations/collection_proxy.rb | 2 ++ activerecord/lib/active_record/null_relation.rb | 6 ++++-- activerecord/lib/active_record/relation/calculations.rb | 12 ++++++++++++ 4 files changed, 20 insertions(+), 2 deletions(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/associations/collection_association.rb b/activerecord/lib/active_record/associations/collection_association.rb index 109ad71ff9..e7bcc59354 100644 --- a/activerecord/lib/active_record/associations/collection_association.rb +++ b/activerecord/lib/active_record/associations/collection_association.rb @@ -194,6 +194,8 @@ module ActiveRecord # Count all records using SQL. Construct options and pass them with # scope to the target class's +count+. def count(column_name = nil, count_options = {}) + # TODO: Remove count_options argument as soon we remove support to + # activerecord-deprecated_finders. column_name, count_options = nil, column_name if column_name.is_a?(Hash) relation = scope diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb index 6e2b559e4b..0dabe256e3 100644 --- a/activerecord/lib/active_record/associations/collection_proxy.rb +++ b/activerecord/lib/active_record/associations/collection_proxy.rb @@ -670,6 +670,8 @@ module ActiveRecord # # # # # ] def count(column_name = nil, options = {}) + # TODO: Remove options argument as soon we remove support to + # activerecord-deprecated_finders. @association.count(column_name, options) end diff --git a/activerecord/lib/active_record/null_relation.rb b/activerecord/lib/active_record/null_relation.rb index 62c6bbc413..5b255c3fe5 100644 --- a/activerecord/lib/active_record/null_relation.rb +++ b/activerecord/lib/active_record/null_relation.rb @@ -50,8 +50,10 @@ module ActiveRecord 0 end - def calculate(_operation, _column_name, _options = {}) - if _operation == :count + def calculate(operation, _column_name, _options = {}) + # TODO: Remove _options argument as soon we remove support to + # activerecord-deprecated_finders. + if operation == :count 0 else nil diff --git a/activerecord/lib/active_record/relation/calculations.rb b/activerecord/lib/active_record/relation/calculations.rb index 1d81b50abb..45ffb99868 100644 --- a/activerecord/lib/active_record/relation/calculations.rb +++ b/activerecord/lib/active_record/relation/calculations.rb @@ -20,6 +20,8 @@ module ActiveRecord # Person.group(:city).count # # => { 'Rome' => 5, 'Paris' => 3 } def count(column_name = nil, options = {}) + # TODO: Remove options argument as soon we remove support to + # activerecord-deprecated_finders. column_name, options = nil, column_name if column_name.is_a?(Hash) calculate(:count, column_name, options) end @@ -29,6 +31,8 @@ module ActiveRecord # # Person.average(:age) # => 35.8 def average(column_name, options = {}) + # TODO: Remove options argument as soon we remove support to + # activerecord-deprecated_finders. calculate(:average, column_name, options) end @@ -38,6 +42,8 @@ module ActiveRecord # # Person.minimum(:age) # => 7 def minimum(column_name, options = {}) + # TODO: Remove options argument as soon we remove support to + # activerecord-deprecated_finders. calculate(:minimum, column_name, options) end @@ -47,6 +53,8 @@ module ActiveRecord # # Person.maximum(:age) # => 93 def maximum(column_name, options = {}) + # TODO: Remove options argument as soon we remove support to + # activerecord-deprecated_finders. calculate(:maximum, column_name, options) end @@ -91,6 +99,8 @@ module ActiveRecord # # Person.sum("2 * age") def calculate(operation, column_name, options = {}) + # TODO: Remove options argument as soon we remove support to + # activerecord-deprecated_finders. if column_name.is_a?(Symbol) && attribute_alias?(column_name) column_name = attribute_alias(column_name) end @@ -182,6 +192,8 @@ module ActiveRecord end def perform_calculation(operation, column_name, options = {}) + # TODO: Remove options argument as soon we remove support to + # activerecord-deprecated_finders. operation = operation.to_s.downcase # If #count is used with #distinct / #uniq it is considered distinct. (eg. relation.distinct.count) -- cgit v1.2.3