Skip to content

Commit da25bd7

Browse files
committed
Fix: Large table causes sql error
Signed-off-by: Kostiantyn Miakshyn <molodchick@gmail.com>
1 parent 20b49b6 commit da25bd7

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

lib/Db/Row2Mapper.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
use Throwable;
2929

3030
class Row2Mapper {
31+
private const ROWS_LOADING_CHUNK_SIZE = 5000;
32+
3133
use TTransactional;
3234

3335
private RowSleeveMapper $rowSleeveMapper;
@@ -193,6 +195,16 @@ public function findAll(array $showColumnIds, int $tableId, ?int $limit = null,
193195
* @throws InternalError
194196
*/
195197
private function getRows(array $rowIds, array $columnIds): array {
198+
if (count($rowIds) > self::ROWS_LOADING_CHUNK_SIZE) {
199+
$chunks = [];
200+
do {
201+
$chunkRowIds = array_splice($rowIds, 0, self::ROWS_LOADING_CHUNK_SIZE);
202+
$chunks[] = $this->getRows($chunkRowIds, $columnIds);
203+
} while (count($rowIds) > self::ROWS_LOADING_CHUNK_SIZE);
204+
205+
return array_merge(...$chunks);
206+
}
207+
196208
$qb = $this->db->getQueryBuilder();
197209

198210
$qbSqlForColumnTypes = null;

0 commit comments

Comments
 (0)