Permalink
Browse files

refactoring to remove duplicate logic

  • Loading branch information...
tenderlove committed Aug 18, 2010
1 parent 7e85b16 commit 2f6383e340481e40f8b9e02eee4fd94e0c0a3b7a
Showing with 3 additions and 4 deletions.
  1. +3 −4 activerecord/lib/active_record/relation/calculations.rb
@@ -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

0 comments on commit 2f6383e

Please sign in to comment.