Use count in stead of .any for offset iteration presence checking
This commit is contained in:
@@ -10,8 +10,9 @@ module ActiveRecord
|
||||
limit=arel.limit
|
||||
if limit && (limit < batch_size) then batch_size = limit end
|
||||
records = self.offset(offset).limit(batch_size).all
|
||||
while records.any?
|
||||
offset += records.size
|
||||
records_count = records.count
|
||||
while records_count > 0
|
||||
offset += records_count
|
||||
records.each { |r| yield r }
|
||||
if limit then
|
||||
limit -= records.size
|
||||
@@ -21,6 +22,7 @@ module ActiveRecord
|
||||
end
|
||||
end
|
||||
records = self.offset(offset).limit(batch_size).all
|
||||
records_count = records.count
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user