Permalink
Browse files

Don't use regular rinder on calculations since scoping order blows

PostreSQL.
  • Loading branch information...
1 parent 48c1e6d commit 796ec652ade1bfbf074fc1cfd2cd2e7794f494bc @miloops miloops committed Aug 14, 2009
Showing with 7 additions and 1 deletion.
  1. +7 −1 activerecord/lib/active_record/calculations.rb
View
8 activerecord/lib/active_record/calculations.rb
@@ -146,7 +146,13 @@ def calculate(operation, column_name, options = {})
join_dependency = ActiveRecord::Associations::ClassMethods::JoinDependency.new(self, merged_includes, construct_join(options[:joins], scope))
construct_finder_arel_with_included_associations(options, join_dependency)
else
- construct_finder_arel(options)
+ arel_table(options[:from]).
+ join(construct_join(options[:joins], scope)).
+ where(construct_conditions(options[:conditions], scope)).
+ group(construct_group(options[:group], options[:having], scope)).
+ order(options[:order]).
+ take(options[:limit]).
+ skip(options[:offset])
end
if options[:group]
return execute_grouped_calculation(operation, column_name, options, relation)

0 comments on commit 796ec65

Please sign in to comment.