diff options
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/relation/batches.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/batches_test.rb | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/relation/batches.rb b/activerecord/lib/active_record/relation/batches.rb index 4d14506965..28aab6d92b 100644 --- a/activerecord/lib/active_record/relation/batches.rb +++ b/activerecord/lib/active_record/relation/batches.rb @@ -62,7 +62,7 @@ module ActiveRecord 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) diff --git a/activerecord/test/cases/batches_test.rb b/activerecord/test/cases/batches_test.rb index 78d89aa232..4016f5f309 100644 --- a/activerecord/test/cases/batches_test.rb +++ b/activerecord/test/cases/batches_test.rb @@ -128,14 +128,14 @@ class EachTest < ActiveRecord::TestCase 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 |