From 1ea79078d9675c4974fa85925a9ad4d8ffe199cf Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 17 Sep 2025 11:20:05 +0300 Subject: [PATCH 1/2] fix --- src/ActiveQuery.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ActiveQuery.php b/src/ActiveQuery.php index d56b12a3f..f6356a102 100644 --- a/src/ActiveQuery.php +++ b/src/ActiveQuery.php @@ -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; @@ -843,9 +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 { - return ArArrayHelper::index($this->populate($rows), $this->indexBy); + return ArArrayHelper::index($this->populate(array_values($rows)), $this->indexBy); } private function createInstance(): static From 3962e6f7371da4dd0456199934f14cb432ff12d0 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 17 Sep 2025 11:21:38 +0300 Subject: [PATCH 2/2] fix --- src/ActiveQuery.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ActiveQuery.php b/src/ActiveQuery.php index f6356a102..9a059fed1 100644 --- a/src/ActiveQuery.php +++ b/src/ActiveQuery.php @@ -852,7 +852,8 @@ public function batch(int $batchSize = 100): BatchQueryResultInterface protected function index(array $rows): array { - return ArArrayHelper::index($this->populate(array_values($rows)), $this->indexBy); + /** @var list $rows */ + return ArArrayHelper::index($this->populate($rows), $this->indexBy); } private function createInstance(): static