From 55622e0bde999193ae4a848d28cf2ce7e9247d83 Mon Sep 17 00:00:00 2001 From: Frederick Cheung Date: Mon, 21 Apr 2008 11:47:15 +1200 Subject: Avoid adding two DISTINCT statements to queries in sqlite 2. --- activerecord/lib/active_record/calculations.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/calculations.rb b/activerecord/lib/active_record/calculations.rb index 64527ec3f0..b5bf82ee11 100644 --- a/activerecord/lib/active_record/calculations.rb +++ b/activerecord/lib/active_record/calculations.rb @@ -178,7 +178,7 @@ module ActiveRecord sql = "SELECT COUNT(*) AS #{aggregate_alias}" if use_workaround sql << ", #{options[:group_field]} AS #{options[:group_alias]}" if options[:group] - sql << " FROM (SELECT DISTINCT #{column_name}" if use_workaround + sql << " FROM (SELECT #{distinct}#{column_name}" if use_workaround sql << " FROM #{connection.quote_table_name(table_name)} " if merged_includes.any? join_dependency = ActiveRecord::Associations::ClassMethods::JoinDependency.new(self, merged_includes, options[:joins]) -- cgit v1.2.3