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
|
limit=arel.limit
|
||||||
if limit && (limit < batch_size) then batch_size = limit end
|
if limit && (limit < batch_size) then batch_size = limit end
|
||||||
records = self.offset(offset).limit(batch_size).all
|
records = self.offset(offset).limit(batch_size).all
|
||||||
while records.any?
|
records_count = records.count
|
||||||
offset += records.size
|
while records_count > 0
|
||||||
|
offset += records_count
|
||||||
records.each { |r| yield r }
|
records.each { |r| yield r }
|
||||||
if limit then
|
if limit then
|
||||||
limit -= records.size
|
limit -= records.size
|
||||||
@@ -21,6 +22,7 @@ module ActiveRecord
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
records = self.offset(offset).limit(batch_size).all
|
records = self.offset(offset).limit(batch_size).all
|
||||||
|
records_count = records.count
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user