diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2010-01-16 22:05:01 +0530 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2010-01-16 22:05:01 +0530 |
commit | f80be3ea0fa2bb3416e180901d441b0834001c7f (patch) | |
tree | 9b0b7f60cd96190a02a292578357f6071c68077b /activerecord | |
parent | 61e831564aa4b22983646ecdc15d43991bc0e522 (diff) | |
download | rails-f80be3ea0fa2bb3416e180901d441b0834001c7f.tar.gz rails-f80be3ea0fa2bb3416e180901d441b0834001c7f.tar.bz2 rails-f80be3ea0fa2bb3416e180901d441b0834001c7f.zip |
Use Relation#apply_finder_options from calculations
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/calculations.rb | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/activerecord/lib/active_record/calculations.rb b/activerecord/lib/active_record/calculations.rb index cd7bd185c5..a79ceb1d05 100644 --- a/activerecord/lib/active_record/calculations.rb +++ b/activerecord/lib/active_record/calculations.rb @@ -163,14 +163,7 @@ module ActiveRecord join_dependency = ActiveRecord::Associations::ClassMethods::JoinDependency.new(self, includes, construct_join(joins)) construct_calculation_arel_with_included_associations(options, join_dependency, merge_with_relation) else - relation = active_relation. - joins(options[:joins]). - where(options[:conditions]). - order(options[:order]). - limit(options[:limit]). - offset(options[:offset]). - group(options[:group]). - having(options[:having]) + relation = active_relation.apply_finder_options(options.slice(:joins, :conditions, :order, :limit, :offset, :group, :having)) if merge_with_relation relation = merge_with_relation.except(:select, :order, :limit, :offset, :group, :from).merge(relation) @@ -205,14 +198,8 @@ module ActiveRecord relation = relation.where(type_condition) if finder_needs_type_condition? end - relation = relation.joins(options[:joins]). - select(column_aliases(join_dependency)). - group(options[:group]). - having(options[:having]). - order(options[:order]). - where(options[:conditions]). - from(options[:from]) - + relation = relation.apply_finder_options(options.slice(:joins, :group, :having, :order, :conditions, :from)). + select(column_aliases(join_dependency)) if !using_limitable_reflections?(join_dependency.reflections) && (merge_limit || options[:limit]) relation = relation.where(construct_arel_limited_ids_condition(options, join_dependency)) |