Permalink
Browse files

start could be a string

Related to 761bc75 and
eb876c4
  • Loading branch information...
spastorino committed Sep 21, 2012
1 parent eb876c4 commit 5b99cf088c89eba655adc588af40b1970fdd76a9
Showing with 3 additions and 3 deletions.
  1. +1 −1 activerecord/lib/active_record/relation/batches.rb
  2. +2 −2 activerecord/test/cases/batches_test.rb
@@ -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

2 comments on commit 5b99cf0

@rafaelfranca

This comment has been minimized.

Show comment Hide comment
@rafaelfranca

rafaelfranca Sep 22, 2012

Owner

The build is still broken.

Owner

rafaelfranca replied Sep 22, 2012

The build is still broken.

@spastorino

This comment has been minimized.

Show comment Hide comment
@spastorino

spastorino Sep 22, 2012

Owner

Fixed 19fa8fa

Owner

spastorino replied Sep 22, 2012

Fixed 19fa8fa

Please sign in to comment.