aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2017-07-20 12:13:11 +0900
committerRyuta Kamizono <kamipo@gmail.com>2017-07-22 08:40:16 +0900
commit0df0dfbfac91c2cc4dce1ae73d4026121d109275 (patch)
treefcb94a632f73860e730695df9676c4c57e56a371 /activerecord/lib/active_record
parenta265d4b29cf9c1be84603ec53a6f8b17b53321a9 (diff)
downloadrails-0df0dfbfac91c2cc4dce1ae73d4026121d109275.tar.gz
rails-0df0dfbfac91c2cc4dce1ae73d4026121d109275.tar.bz2
rails-0df0dfbfac91c2cc4dce1ae73d4026121d109275.zip
Should keep the table name qualified `*` for distinct subquery
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/relation/calculations.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation/calculations.rb b/activerecord/lib/active_record/relation/calculations.rb
index a4714f138a..d281f8673f 100644
--- a/activerecord/lib/active_record/relation/calculations.rb
+++ b/activerecord/lib/active_record/relation/calculations.rb
@@ -388,7 +388,7 @@ module ActiveRecord
def build_count_subquery(relation, column_name, distinct)
relation.select_values = [
if column_name == :all
- distinct ? Arel.star : Arel.sql("1")
+ distinct ? table[Arel.star] : Arel.sql("1")
else
column_alias = Arel.sql("count_column")
aggregate_column(column_name).as(column_alias)