Permalink
Browse files

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
  • Loading branch information...
Marcel Molina
Marcel Molina committed Apr 28, 2006
1 parent 2ec1527 commit 0dc53a8f6f024c5ca7afba7ada498a26ab888c0f
Showing with 7 additions and 1 deletion.
  1. +2 −0 activerecord/CHANGELOG
  2. +5 −1 activerecord/lib/active_record/calculations.rb
View
@@ -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]
@@ -173,7 +173,11 @@ def construct_calculation_sql(operation, column_name, options) #:nodoc:
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

0 comments on commit 0dc53a8

Please sign in to comment.