aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations
diff options
context:
space:
mode:
authorYves Senn <yves.senn@gmail.com>2013-03-12 10:52:25 +0100
committerYves Senn <yves.senn@gmail.com>2013-03-15 14:15:47 +0100
commitcd87c85ef05e47f6ea1ce7422ae033fe6d82b030 (patch)
treed4a74669f3f5a9dd8900b688e4e00481c0a8b1e9 /activerecord/lib/active_record/associations
parenta1bb6c8b06db83546179175b9b2dde7912c86f9b (diff)
downloadrails-cd87c85ef05e47f6ea1ce7422ae033fe6d82b030.tar.gz
rails-cd87c85ef05e47f6ea1ce7422ae033fe6d82b030.tar.bz2
rails-cd87c85ef05e47f6ea1ce7422ae033fe6d82b030.zip
Deprecate the `:distinct` option for `Relation#count`.
We moved more and more away from passing options to finder / calculation methods. The `:distinct` option in `#count` was one of the remaining places. Since we can now combine `Relation#distinct` with `Relation#count` the option is no longer necessary and can be deprecated.
Diffstat (limited to 'activerecord/lib/active_record/associations')
-rw-r--r--activerecord/lib/active_record/associations/collection_association.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/associations/collection_association.rb b/activerecord/lib/active_record/associations/collection_association.rb
index 552f7f1117..18b7dc3668 100644
--- a/activerecord/lib/active_record/associations/collection_association.rb
+++ b/activerecord/lib/active_record/associations/collection_association.rb
@@ -174,13 +174,14 @@ module ActiveRecord
reflection.klass.count_by_sql(custom_counter_sql)
else
+ relation = scope
if association_scope.distinct_value
# This is needed because 'SELECT count(DISTINCT *)..' is not valid SQL.
column_name ||= reflection.klass.primary_key
- count_options[:distinct] = true
+ relation = relation.distinct
end
- value = scope.count(column_name, count_options)
+ value = relation.count(column_name)
limit = options[:limit]
offset = options[:offset]