Skip to content

Commit 6c24c0e

Browse files
Anton EversAnton Evers
authored andcommitted
Ranged selects always miss the last range
Fix unit test. 11 batches expected to handle 105 items: 1: 1-10 2: 11-20 3: 21-30 4: 31-40 5: 41-50 6: 51-60 7: 61-70 8: 71-80 9: 81-90 10: 91-100 11: 101-105
1 parent f93b914 commit 6c24c0e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/internal/Magento/Framework/DB/Query/BatchRangeIterator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public function __construct(
113113
public function current()
114114
{
115115
if (null === $this->currentSelect) {
116-
$this->isValid = ($this->currentOffset + $this->batchSize) <= $this->totalItemCount;
116+
$this->isValid = $this->currentOffset < $this->totalItemCount;
117117
$this->currentSelect = $this->initSelectObject();
118118
}
119119
return $this->currentSelect;
@@ -144,7 +144,7 @@ public function next()
144144
if (null === $this->currentSelect) {
145145
$this->current();
146146
}
147-
$this->isValid = ($this->batchSize + $this->currentOffset) <= $this->totalItemCount;
147+
$this->isValid = $this->currentOffset < $this->totalItemCount;
148148
$select = $this->initSelectObject();
149149
if ($this->isValid) {
150150
$this->iteration++;

lib/internal/Magento/Framework/Test/Unit/DB/Query/BatchRangeIteratorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,6 @@ public function testIterations()
116116
$iterations++;
117117
}
118118

119-
$this->assertEquals(10, $iterations);
119+
$this->assertEquals(11, $iterations);
120120
}
121121
}

0 commit comments

Comments
 (0)