From 0dc53a8f6f024c5ca7afba7ada498a26ab888c0f Mon Sep 17 00:00:00 2001 From: Marcel Molina Date: Fri, 28 Apr 2006 01:12:18 +0000 Subject: When grouping, use the appropriate option key. [Marcel Molina Jr.] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4297 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/CHANGELOG | 2 ++ activerecord/lib/active_record/calculations.rb | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'activerecord') diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index 9540d6fc17..da08d14816 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* When grouping, use the appropriate option key. [Marcel Molina Jr.] + * Only modify the sequence name in the FrontBase adapter if the FrontBase adapter is actually being used. [Marcel Molina Jr.] * Add support for FrontBase (http://www.frontbase.com/) with a new adapter thanks to the hard work of one Mike Laster. Closes #4093. [mlaster@metavillage.com] diff --git a/activerecord/lib/active_record/calculations.rb b/activerecord/lib/active_record/calculations.rb index 7a25bd4aa1..e16bf9e6d7 100644 --- a/activerecord/lib/active_record/calculations.rb +++ b/activerecord/lib/active_record/calculations.rb @@ -173,7 +173,11 @@ module ActiveRecord add_joins!(sql, options, scope) add_conditions!(sql, options[:conditions], scope) add_limited_ids_condition!(sql, options, join_dependency) if join_dependency && !using_limitable_reflections?(join_dependency.reflections) && ((scope && scope[:limit]) || options[:limit]) - sql << " GROUP BY #{options[:group_alias]} " if options[:group] + + if options[:group] + group_key = Base.connection.adapter_name == 'FrontBase' ? :group_alias : :group_field + sql << " GROUP BY #{options[group_key]} " + end if options[:group] && options[:having] # FrontBase requires identifiers in the HAVING clause and chokes on function calls -- cgit v1.2.3