From 0407f9bf219823beb4f18e36b03d4e924dddbcae Mon Sep 17 00:00:00 2001 From: Valentin Mihov Date: Thu, 11 Jun 2009 17:32:59 +0300 Subject: [PATCH 2/2] Added with_exclusive_scope around the find_in_batches method --- activerecord/lib/active_record/batches.rb | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/activerecord/lib/active_record/batches.rb b/activerecord/lib/active_record/batches.rb index e41d38f..1cab579 100644 --- a/activerecord/lib/active_record/batches.rb +++ b/activerecord/lib/active_record/batches.rb @@ -61,7 +61,9 @@ module ActiveRecord records = find(:all, :conditions => [ "#{table_name}.#{primary_key} >= ?", start ]) while records.any? - yield records + with_exclusive_scope do + yield records + end break if records.size < batch_size records = find(:all, :conditions => [ "#{table_name}.#{primary_key} > ?", records.last.id ]) -- 1.6.1.3