rails/rails — pull request #6792 by Empact (2012-06-20 08:41:08+00:00)
Title: Alternative fix for #6523, wherein #exists? and other methods generate invalid SELECT DISTINCT DISTINCT sql.

Rather than build a select distinct clause in #construct_limited_ids_condition,
I set #uniq_value to true and pass an array of select distinct values into the
select statement. This requires changing the #distinct method to return the
select values but not the statement itself, so I renamed it
to #select_distinct_values. #distinct can easily be reimplemented in terms
of #select_distinct_values if that's necessary despite Rails 4.