1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

[skip ci] #distinct instead of #uniq

as #uniq will be removed from Rails 5.0 as per the Active Support
exception raised:

ActiveSupport::DeprecationException: DEPRECATION WARNING: uniq is
deprecated and will be removed from Rails 5.0 (use distinct instead).
This commit is contained in:
Jon Atack 2015-07-03 11:11:59 +02:00
parent 626b10ef1f
commit 64401610b5

View file

@ -139,7 +139,7 @@ module ActiveRecord
# # SELECT people.id, people.name FROM people
# # => [[1, 'David'], [2, 'Jeremy'], [3, 'Jose']]
#
# Person.uniq.pluck(:role)
# Person.distinct.pluck(:role)
# # SELECT DISTINCT role FROM people
# # => ['admin', 'member', 'guest']
#
@ -195,7 +195,8 @@ module ActiveRecord
def perform_calculation(operation, column_name)
operation = operation.to_s.downcase
# If #count is used with #distinct / #uniq it is considered distinct. (eg. relation.distinct.count)
# If #count is used with #distinct (i.e. `relation.distinct.count`) it is
# considered distinct.
distinct = self.distinct_value
if operation == "count"