Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport of #1997 #2004

Merged
merged 1 commit into from Jul 7, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions activerecord/lib/active_record/relation/batches.rb
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions activerecord/test/cases/batches_test.rb
Expand Up @@ -17,6 +17,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 }
Expand Down