提交 5b99cf08 编写于 作者: S Santiago Pastorino

start could be a string

Related to 761bc751 and
eb876c4d
上级 eb876c4d
......@@ -62,7 +62,7 @@ def find_in_batches(options = {})
ActiveRecord::Base.logger.warn("Scoped order and limit are ignored, it's forced to be batch order and batch size")
end
start = options.delete(:start).to_i
start = options.delete(:start) || 0
batch_size = options.delete(:batch_size) || 1000
relation = relation.reorder(batch_order).limit(batch_size)
......
......@@ -128,14 +128,14 @@ def test_find_in_batches_should_use_any_column_as_primary_key
old_primary_key = Post.primary_key
Post.primary_key = :title
title_order_posts = Post.order('title asc')
start_title = title_order_posts.first.title
start_title = title_order_posts.second.title
posts = []
Post.find_in_batches(:batch_size => 1, :start => start_title) do |batch|
posts.concat(batch)
end
assert_equal title_order_posts.map(&:id), posts.map(&:id)
assert_equal title_order_posts[1..-1].map(&:id), posts.map(&:id)
ensure
Post.primary_key = old_primary_key
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册