method

ensure_valid_options_for_batching!

Importance_0
v8.1.1 - Show latest stable - 0 notes - Class: ActiveRecord::Batches
  • 1.0.0
  • 1.1.6
  • 1.2.6
  • 2.0.3
  • 2.1.0
  • 2.2.1
  • 2.3.8
  • 3.0.0
  • 3.0.9
  • 3.1.0
  • 3.2.1
  • 3.2.8
  • 3.2.13
  • 4.0.2
  • 4.1.8
  • 4.2.1
  • 4.2.7
  • 4.2.9
  • 5.0.0.1
  • 5.1.7
  • 5.2.3
  • 6.0.0
  • 6.1.3.1
  • 6.1.7.7
  • 7.0.0
  • 7.1.3.2
  • 7.1.3.4
  • 7.2.3
  • 8.0.0 (0)
  • 8.1.1 (0)
  • What's this?
ensure_valid_options_for_batching!(cursor, start, finish, order) private

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# 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
Register or log in to add new notes.