rails/rails — pull request #3342 by sbounmy (2011-10-16 03:52:57+00:00)
Title: bug in find_in_batches with scoped_methods

Doing a find in a batch seems to mixin the find_in_batches scope :

named_scope :containing_the_letter_a, :conditions => "body LIKE '%a%'"
Post.containing_the_letter_a.find_in_batches(:batch_size => 1) do |posts|
Post.all
end

Post.all would have done :

SELECT * FROM `posts`

but it did

SELECT * FROM `posts` WHERE (body LIKE '%a%')

The issue is coming from ActiveRecord::Base#scoped_methods which return the find_in_batches conditions when calling Post.all.
This have been fixed in master but not in 2-3-stable.