diff options
Diffstat (limited to 'activerecord/lib')
-rwxr-xr-x | activerecord/lib/active_record/associations.rb | 4 |
1 files changed, 4 insertions, 0 deletions
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 |