diff options
Diffstat (limited to 'activerecord/lib/active_record/calculations.rb')
-rw-r--r-- | activerecord/lib/active_record/calculations.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/calculations.rb b/activerecord/lib/active_record/calculations.rb index 409466866f..e0ac96c879 100644 --- a/activerecord/lib/active_record/calculations.rb +++ b/activerecord/lib/active_record/calculations.rb @@ -155,7 +155,7 @@ module ActiveRecord if merged_includes.any? && operation.to_s.downcase == 'count' options[:distinct] = true - column_name = [table_name, primary_key] * '.' + column_name = options[:select] || [table_name, primary_key] * '.' end sql = "SELECT #{operation}(#{'DISTINCT ' if options[:distinct]}#{column_name}) AS #{aggregate_alias}" |