From 0df0dfbfac91c2cc4dce1ae73d4026121d109275 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Thu, 20 Jul 2017 12:13:11 +0900 Subject: Should keep the table name qualified `*` for distinct subquery --- activerecord/lib/active_record/relation/calculations.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord/lib/active_record/relation') 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) -- cgit v1.2.3