aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activerecord/CHANGELOG3
-rwxr-xr-xactiverecord/lib/active_record/associations.rb4
2 files changed, 6 insertions, 1 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG
index 401dc6d53f..0ee5f91532 100644
--- a/activerecord/CHANGELOG
+++ b/activerecord/CHANGELOG
@@ -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]
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb
index 21f1992d69..a5da8db206 100755
--- a/activerecord/lib/active_record/associations.rb
+++ b/activerecord/lib/active_record/associations.rb
@@ -1333,6 +1333,8 @@ module ActiveRecord
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)
@@ -1340,7 +1342,9 @@ module ActiveRecord
sql << "ORDER BY #{options[:order]}"
end
end
+
add_limit!(sql, options, scope)
+
return sanitize_sql(sql)
end