Skip to content

Commit d4fb7c9

Browse files
authored
Adapt to batch changes in Yii DB (#454)
1 parent 10cd947 commit d4fb7c9

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/ActiveQuery.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Yiisoft\Db\Exception\InvalidConfigException;
1313
use Yiisoft\Db\Exception\NotSupportedException;
1414
use Yiisoft\Db\Expression\ExpressionInterface;
15+
use Yiisoft\Db\Query\BatchQueryResultInterface;
1516
use Yiisoft\Db\Query\DataReaderInterface;
1617
use Yiisoft\Db\Query\Query;
1718
use Yiisoft\Db\Query\QueryInterface;
@@ -843,8 +844,15 @@ public function getModel(): ActiveRecordInterface
843844
return clone $this->model;
844845
}
845846

847+
public function batch(int $batchSize = 100): BatchQueryResultInterface
848+
{
849+
/** @psalm-suppress InvalidArgument */
850+
return parent::batch($batchSize)->indexBy(null)->resultCallback($this->index(...));
851+
}
852+
846853
protected function index(array $rows): array
847854
{
855+
/** @var list<array> $rows */
848856
return ArArrayHelper::index($this->populate($rows), $this->indexBy);
849857
}
850858

0 commit comments

Comments
 (0)