aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorMarcel Molina <marcel@vernix.org>2006-04-28 01:12:18 +0000
committerMarcel Molina <marcel@vernix.org>2006-04-28 01:12:18 +0000
commit0dc53a8f6f024c5ca7afba7ada498a26ab888c0f (patch)
tree06affa87961c307d839356a7dbfd78f137935a99 /activerecord
parent2ec1527c47f87a2fca64a060ec13bf9ba1101a53 (diff)
downloadrails-0dc53a8f6f024c5ca7afba7ada498a26ab888c0f.tar.gz
rails-0dc53a8f6f024c5ca7afba7ada498a26ab888c0f.tar.bz2
rails-0dc53a8f6f024c5ca7afba7ada498a26ab888c0f.zip
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
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/CHANGELOG2
-rw-r--r--activerecord/lib/active_record/calculations.rb6
2 files changed, 7 insertions, 1 deletions
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