aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2012-09-16 23:27:19 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2012-09-16 23:27:19 -0300
commit9ae79af0421977f5b3ecbc70fc93e98d4278b8f0 (patch)
treea32054798e731d191212599977b0510796e6046a /activerecord/lib
parenteac9e0325c3f050b186328462798f20f5d2969a8 (diff)
parent9fa3f102813eeeec440abd75870dfa7b23835665 (diff)
downloadrails-9ae79af0421977f5b3ecbc70fc93e98d4278b8f0.tar.gz
rails-9ae79af0421977f5b3ecbc70fc93e98d4278b8f0.tar.bz2
rails-9ae79af0421977f5b3ecbc70fc93e98d4278b8f0.zip
Merge pull request #7651 from steveklabnik/issue_3956
Don't preserve SELECT columns on COUNT Closes #7651
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/associations/collection_association.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/collection_association.rb b/activerecord/lib/active_record/associations/collection_association.rb
index b15df4f308..babbb12e99 100644
--- a/activerecord/lib/active_record/associations/collection_association.rb
+++ b/activerecord/lib/active_record/associations/collection_association.rb
@@ -373,7 +373,8 @@ module ActiveRecord
# replace the SELECT clause with COUNT(SELECTS), preserving any hints within /* ... */
interpolate(options[:finder_sql]).sub(/SELECT\b(\/\*.*?\*\/ )?(.*)\bFROM\b/im) do
count_with = $2.to_s
- count_with = '*' if count_with.blank? || count_with =~ /,/
+ p count_with
+ count_with = '*' if count_with.blank? || count_with =~ /,/ || count_with =~ /\.\*/
"SELECT #{$1}COUNT(#{count_with}) FROM"
end
end