def distinct_identities
      # Note that since Rails 2.3.13, when pluck(col) is applied to distinct_identities
      # the "DISTINCT" is lost from the SELECT if added explicitly  as in .select('DISTINCT #{col}'),
      # so we have avoid explicit use of DISTINCT in distinct_identities.
      # This can be used on association queries
      if ActiveRecord::VERSION::MAJOR > 3
        unscope(:select).reorder(identity_column_sql).select(identity_column_sql).uniq
      else
        query = scoped.with_default_scope
        query.select_values.clear
        query.reorder(identity_column_sql).select(identity_column_sql).uniq
      end
    end
def distinct_identities
      # Note that since Rails 2.3.13, when pluck(col) is applied to distinct_identities
      # the "DISTINCT" is lost from the SELECT if added explicitly  as in .select('DISTINCT #{col}'),
      # so we have avoid explicit use of DISTINCT in distinct_identities.
      # This can be used on association queries
      if ActiveRecord::VERSION::MAJOR > 3
        unscope(:select).reorder(identity_column_sql).select(identity_column_sql).uniq
      else
        query = scoped.with_default_scope
        query.select_values.clear
        query.reorder(identity_column_sql).select(identity_column_sql).uniq
      end
    end
Return objects representing identities; (with a single attribute, :identity)
 Warning: do not chain this method after other queries;
 any query should be applied after this method.
 If identities are required for an association, either latest, earliest or initial can be used
 (which one is appropriate depends on desired result, data contents, etc.; initial/current are faster)