diff options
| -rw-r--r-- | activerecord/CHANGELOG | 3 | ||||
| -rw-r--r-- | activerecord/lib/active_record/batches.rb | 4 | ||||
| -rw-r--r-- | activerecord/test/cases/batches_test.rb | 6 | 
3 files changed, 6 insertions, 7 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index 404481ea38..6d2f597004 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,10 +1,9 @@  *2.3.1 [RC2] (March 5, 2009)* -* Added ActiveRecord::Base.each and ActiveRecord::Base.find_in_batches for batch processing [DHH/Jamis Buck] +* Added ActiveRecord::Base.find_each and ActiveRecord::Base.find_in_batches for batch processing [DHH/Jamis Buck]  * Added that ActiveRecord::Base.exists? can be called with no arguments #1817 [Scott Taylor] -  *2.3.0 [RC1] (February 1st, 2009)*  * Add Support for updating deeply nested models from a single form. #1202 [Eloy Duran] diff --git a/activerecord/lib/active_record/batches.rb b/activerecord/lib/active_record/batches.rb index 9e9c8fbbf4..4ea932f34d 100644 --- a/activerecord/lib/active_record/batches.rb +++ b/activerecord/lib/active_record/batches.rb @@ -11,14 +11,14 @@ module ActiveRecord        #        # Example:        # -      #   Person.each(:conditions => "age > 21") do |person| +      #   Person.find_each(:conditions => "age > 21") do |person|        #     person.party_all_night!        #   end        #        # Note: This method is only intended to use for batch processing of large amounts of records that wouldn't fit in        # memory all at once. If you just need to loop over less than 1000 records, it's probably better just to use the        # regular find methods. -      def each(options = {}) +      def find_each(options = {})          find_in_batches(options) do |records|            records.each { |record| yield record }          end diff --git a/activerecord/test/cases/batches_test.rb b/activerecord/test/cases/batches_test.rb index 108d679108..705da9f88e 100644 --- a/activerecord/test/cases/batches_test.rb +++ b/activerecord/test/cases/batches_test.rb @@ -11,7 +11,7 @@ class EachTest < ActiveRecord::TestCase    def test_each_should_excecute_one_query_per_batch      assert_queries(Post.count + 1) do -      Post.each(:batch_size => 1) do |post|  +      Post.find_each(:batch_size => 1) do |post|          assert_kind_of Post, post        end      end @@ -19,13 +19,13 @@ class EachTest < ActiveRecord::TestCase    def test_each_should_raise_if_the_order_is_set      assert_raise(RuntimeError) do -      Post.each(:order => "title") { |post| post } +      Post.find_each(:order => "title") { |post| post }      end    end    def test_each_should_raise_if_the_limit_is_set      assert_raise(RuntimeError) do -      Post.each(:limit => 1) { |post| post } +      Post.find_each(:limit => 1) { |post| post }      end    end  | 
