Permalink
Browse files

Merge pull request #1997 from knapo/master

Make `ActiveRecord::Batches#find_each` to not return `self`.
  • Loading branch information...
2 parents 6469560 + 2ca9b6d commit 63861e0c9c88d9c3f97e5ca9f1a5da014e624f4e @spastorino spastorino committed Jul 7, 2011
Showing with 7 additions and 2 deletions.
  1. +0 −2 activerecord/lib/active_record/relation/batches.rb
  2. +7 −0 activerecord/test/cases/batches_test.rb
@@ -20,8 +20,6 @@ def find_each(options = {})
find_in_batches(options) do |records|
records.each { |record| yield record }
end
-
- self
end
# Yields each batch of records that was found by the find +options+ as
@@ -18,6 +18,13 @@ def test_each_should_excecute_one_query_per_batch
end
end
+ def test_each_should_not_return_query_chain_and_execcute_only_one_query
+ assert_queries(1) do
+ result = Post.find_each(:batch_size => 100000){ }
+ assert_nil result
+ end
+ end
+
def test_each_should_raise_if_select_is_set_without_id
assert_raise(RuntimeError) do
Post.find_each(:select => :title, :batch_size => 1) { |post| post }

0 comments on commit 63861e0

Please sign in to comment.