The combination of a :uniq => true association and the #distinct call
in #construct_limited_ids_condition combine to create invalid SQL, because
we're explicitly selecting DISTINCT, and also sending #distinct on to AREL,
via the relation#uniq_value.
I unset relation#uniq_value in the limited ids lookup so that Arel doesn't
apply the DISTINCT that we're already applying. This only affects the limited
ids lookup query, and only in the problematic case where uniq_value was true.