method

ensure_valid_options_for_batching!

rails latest stable - Class: ActiveRecord::Batches

Method not available on this version

This method is only available on newer versions. The first available version (v8.0.0) is shown here.

ensure_valid_options_for_batching!(cursor, start, finish, order)
private

No documentation available.

# File activerecord/lib/active_record/relation/batches.rb, line 305
      def ensure_valid_options_for_batching!(cursor, start, finish, order)
        if start && Array(start).size != cursor.size
          raise ArgumentError, ":start must contain one value per cursor column"
        end

        if finish && Array(finish).size != cursor.size
          raise ArgumentError, ":finish must contain one value per cursor column"
        end

        if (Array(primary_key) - cursor).any?
          indexes = model.schema_cache.indexes(table_name)
          unique_index = indexes.find { |index| index.unique && index.where.nil? && (Array(index.columns) - cursor).empty? }

          unless unique_index
            raise ArgumentError, ":cursor must include a primary key or other unique column(s)"
          end
        end

        if (Array(order) - [:asc, :desc]).any?
          raise ArgumentError, ":order must be :asc or :desc or an array consisting of :asc or :desc, got #{order.inspect}"
        end
      end