aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation/calculations.rb
diff options
context:
space:
mode:
authorYves Senn <yves.senn@gmail.com>2013-03-12 10:23:08 +0100
committerYves Senn <yves.senn@gmail.com>2013-03-15 14:15:47 +0100
commita1bb6c8b06db83546179175b9b2dde7912c86f9b (patch)
tree136a3a72f5e612b847e953b2ea12bacd53336040 /activerecord/lib/active_record/relation/calculations.rb
parentbfee706b2e8c3f0144588fb034d41c8333bcd88e (diff)
downloadrails-a1bb6c8b06db83546179175b9b2dde7912c86f9b.tar.gz
rails-a1bb6c8b06db83546179175b9b2dde7912c86f9b.tar.bz2
rails-a1bb6c8b06db83546179175b9b2dde7912c86f9b.zip
rename `Relation#uniq` to `Relation#distinct`. `#uniq` still works.
The similarity of `Relation#uniq` to `Array#uniq` is confusing. Since our Relation API is close to SQL terms I renamed `#uniq` to `#distinct`. There is no deprecation. `#uniq` and `#uniq!` are aliases and will continue to work. I also updated the documentation to promote the use of `#distinct`.
Diffstat (limited to 'activerecord/lib/active_record/relation/calculations.rb')
-rw-r--r--activerecord/lib/active_record/relation/calculations.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/relation/calculations.rb b/activerecord/lib/active_record/relation/calculations.rb
index 7f95181c67..6fedfefdee 100644
--- a/activerecord/lib/active_record/relation/calculations.rb
+++ b/activerecord/lib/active_record/relation/calculations.rb
@@ -198,8 +198,8 @@ module ActiveRecord
def perform_calculation(operation, column_name, options = {})
operation = operation.to_s.downcase
- # If #count is used in conjuction with #uniq it is considered distinct. (eg. relation.uniq.count)
- distinct = options[:distinct] || self.uniq_value
+ # If #count is used with #distinct / #uniq it is considered distinct. (eg. relation.distinct.count)
+ distinct = options[:distinct] || self.distinct_value
if operation == "count"
column_name ||= (select_for_count || :all)