method

construct_relation_for_exists

construct_relation_for_exists(conditions)
private

No documentation available.

# File activerecord/lib/active_record/relation/finder_methods.rb, line 439
      def construct_relation_for_exists(conditions)
        conditions = sanitize_forbidden_attributes(conditions)

        if distinct_value && offset_value
          relation = except(:order).limit!(1)
        else
          relation = except(:select, :distinct, :order)._select!(Arel.sql(ONE_AS_ONE, retryable: true)).limit!(1)
        end

        case conditions
        when Array, Hash
          relation.where!(conditions) unless conditions.empty?
        else
          relation.where!(primary_key => conditions) unless conditions == :none
        end

        relation
      end