提交 929c2261 编写于 作者: R Rafael Mendonça França

Mark the arguments needed by activerecord-deprecated_finders with a TODO

上级 e1ce0059
......@@ -194,6 +194,8 @@ def destroy_all
# 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
......
......@@ -670,6 +670,8 @@ def distinct
# # #<Pet id: 3, name: "Choo-Choo", person_id: 1>
# # ]
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
......
......@@ -50,8 +50,10 @@ def sum(*)
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
......
......@@ -20,6 +20,8 @@ module Calculations
# 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 @@ def count(column_name = nil, options = {})
#
# 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 @@ def average(column_name, options = {})
#
# 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 @@ def minimum(column_name, options = {})
#
# 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 @@ def sum(*args)
#
# 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 @@ def has_include?(column_name)
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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册