diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-06-03 21:19:36 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-06-03 21:19:36 +0000 |
commit | 4394e402b7a482675ceb5ab9e832defe930bd71e (patch) | |
tree | 2ac0fdd10f15f799bb24d924f3baff49dcfe1b15 /activerecord/lib | |
parent | 16716090632d499eb6bfc8afdea2784eb6f5963d (diff) | |
download | rails-4394e402b7a482675ceb5ab9e832defe930bd71e.tar.gz rails-4394e402b7a482675ceb5ab9e832defe930bd71e.tar.bz2 rails-4394e402b7a482675ceb5ab9e832defe930bd71e.zip |
Fixed that count distinct should use the selected column even when using :include (closes #5251) [anna@wota.jp]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4417 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib')
-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}" |