提交 e4f424d5 编写于 作者: A Aaron Patterson

refactoring to remove duplicate logic

上级 93f335b6
......@@ -163,6 +163,8 @@ def calculate(operation, column_name, options = {})
def perform_calculation(operation, column_name, options = {})
operation = operation.to_s.downcase
distinct = nil
if operation == "count"
column_name ||= (select_for_count || :all)
......@@ -171,10 +173,7 @@ def perform_calculation(operation, column_name, options = {})
column_name = @klass.primary_key if column_name == :all
end
distinct = nil if column_name.to_s =~ /\s*DISTINCT\s+/i
distinct ||= options[:distinct]
else
distinct = nil
distinct = nil if column_name =~ /\s*DISTINCT\s+/i
end
distinct = options[:distinct] || distinct
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册