Skip to content
This repository
Browse code

start could be a string

Related to 761bc75 and
eb876c4
  • Loading branch information...
commit 5b99cf088c89eba655adc588af40b1970fdd76a9 1 parent eb876c4
Santiago Pastorino spastorino authored
2  activerecord/lib/active_record/relation/batches.rb
@@ -62,7 +62,7 @@ def find_in_batches(options = {})
62 62 ActiveRecord::Base.logger.warn("Scoped order and limit are ignored, it's forced to be batch order and batch size")
63 63 end
64 64
65   - start = options.delete(:start).to_i
  65 + start = options.delete(:start) || 0
66 66 batch_size = options.delete(:batch_size) || 1000
67 67
68 68 relation = relation.reorder(batch_order).limit(batch_size)
4 activerecord/test/cases/batches_test.rb
@@ -128,14 +128,14 @@ def test_find_in_batches_should_use_any_column_as_primary_key
128 128 old_primary_key = Post.primary_key
129 129 Post.primary_key = :title
130 130 title_order_posts = Post.order('title asc')
131   - start_title = title_order_posts.first.title
  131 + start_title = title_order_posts.second.title
132 132
133 133 posts = []
134 134 Post.find_in_batches(:batch_size => 1, :start => start_title) do |batch|
135 135 posts.concat(batch)
136 136 end
137 137
138   - assert_equal title_order_posts.map(&:id), posts.map(&:id)
  138 + assert_equal title_order_posts[1..-1].map(&:id), posts.map(&:id)
139 139 ensure
140 140 Post.primary_key = old_primary_key
141 141 end

2 comments on commit 5b99cf0

Rafael Mendonça França

The build is still broken.

Santiago Pastorino

Fixed 19fa8fa

Please sign in to comment.
Something went wrong with that request. Please try again.