Permalink
Browse files

Fixed that eager loading queries should respect the :group option as …

…well [DHH]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7354 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 0fc77b3 commit 0e452bb02d7437a5e67fdb41f6a1f77289e7ddbd @dhh dhh committed Aug 21, 2007
Showing with 6 additions and 1 deletion.
  1. +2 −1 activerecord/CHANGELOG
  2. +4 −0 activerecord/lib/active_record/associations.rb
View
@@ -1,5 +1,7 @@
*SVN*
+* Fixed that eager loading queries should respect the :group option as well [DHH]
+
* Improve performance and functionality of the postgresql adapter. Closes #8049 [roderickvd]
For more information see: http://dev.rubyonrails.org/ticket/8049
@@ -14,7 +16,6 @@
- Move method definition to the class, instead of the instance
- Always generate the readers, writers and predicate methods.
-
* Perform a deep #dup on query cache results so that modifying activerecord attributes does not modify the cached attributes. [Rick]
# Ensure that has_many :through associations use a count query instead of loading the target when #size is called. Closes #8800 [lifo]
@@ -1333,14 +1333,18 @@ def construct_finder_sql_for_association_limiting(options, join_dependency)
end
add_conditions!(sql, options[:conditions], scope)
+ sql << " GROUP BY #{options[:group]} " if options[:group]
+
if options[:order]
if is_distinct
connection.add_order_by_for_association_limiting!(sql, options)
else
sql << "ORDER BY #{options[:order]}"
end
end
+
add_limit!(sql, options, scope)
+
return sanitize_sql(sql)
end

0 comments on commit 0e452bb

Please sign in to comment.