instance method
ensure_valid_options_for_batching!
Ruby on Rails 8.1.2
Since v8.0.4 PrivateAvailable in: v8.0.4 v8.1.2
Signature
ensure_valid_options_for_batching!(cursor, start, finish, order)
No documentation comment.
Parameters
-
cursorreq -
startreq -
finishreq -
orderreq
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
Defined in activerecord/lib/active_record/relation/batches.rb line 305
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::Batches