Merge pull request #11161 from dmitry/find_in_batches_works_without_logger
ActiveRecord find_in_batches should work without logger When I set logger to nil both methods from Batches module find_in_batches or find_each should work anyway.
This commit is contained in:
commit
8f63515f6e
|
@ -89,8 +89,8 @@ module ActiveRecord
|
|||
|
||||
relation = self
|
||||
|
||||
unless arel.orders.blank? && arel.taken.blank?
|
||||
ActiveRecord::Base.logger.warn("Scoped order and limit are ignored, it's forced to be batch order and batch size")
|
||||
if logger && (arel.orders.present? || arel.taken.present?)
|
||||
logger.warn("Scoped order and limit are ignored, it's forced to be batch order and batch size")
|
||||
end
|
||||
|
||||
start = options.delete(:start)
|
||||
|
|
|
@ -68,6 +68,16 @@ class EachTest < ActiveRecord::TestCase
|
|||
Post.order("title").find_each { |post| post }
|
||||
end
|
||||
|
||||
def test_logger_not_required
|
||||
previous_logger = ActiveRecord::Base.logger
|
||||
ActiveRecord::Base.logger = nil
|
||||
assert_nothing_raised do
|
||||
Post.limit(1).find_each { |post| post }
|
||||
end
|
||||
ensure
|
||||
ActiveRecord::Base.logger = previous_logger
|
||||
end
|
||||
|
||||
def test_find_in_batches_should_return_batches
|
||||
assert_queries(@total + 1) do
|
||||
Post.find_in_batches(:batch_size => 1) do |batch|
|
||||
|
|
Loading…
Reference in New Issue