Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/ActiveQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Yiisoft\Db\Exception\InvalidConfigException;
use Yiisoft\Db\Exception\NotSupportedException;
use Yiisoft\Db\Expression\ExpressionInterface;
use Yiisoft\Db\Query\BatchQueryResultInterface;
use Yiisoft\Db\Query\DataReaderInterface;
use Yiisoft\Db\Query\Query;
use Yiisoft\Db\Query\QueryInterface;
Expand Down Expand Up @@ -843,8 +844,15 @@ public function getModel(): ActiveRecordInterface
return clone $this->model;
}

public function batch(int $batchSize = 100): BatchQueryResultInterface
{
/** @psalm-suppress InvalidArgument */
return parent::batch($batchSize)->indexBy(null)->resultCallback($this->index(...));
}

protected function index(array $rows): array
{
/** @var list<array> $rows */
return ArArrayHelper::index($this->populate($rows), $this->indexBy);
}

Expand Down
Loading