From 0869ba4618bbccc202e87ea1bde7263c9af8a2df Mon Sep 17 00:00:00 2001 From: mertmit Date: Mon, 22 Apr 2024 07:16:40 +0000 Subject: [PATCH] fix: bulk update small chunks --- packages/nocodb/src/db/BaseModelSqlv2.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/nocodb/src/db/BaseModelSqlv2.ts b/packages/nocodb/src/db/BaseModelSqlv2.ts index 9b0673f647..095e894086 100644 --- a/packages/nocodb/src/db/BaseModelSqlv2.ts +++ b/packages/nocodb/src/db/BaseModelSqlv2.ts @@ -3711,7 +3711,7 @@ class BaseModelSqlv2 { const toBeUpdated = []; const toRead = []; const readChunkSize = 100; - for (const d of updateDatas) { + for (const [i, d] of updateDatas.entries()) { const pkValues = this._extractPksValues(d); if (!pkValues) { // throw or skip if no pk provided @@ -3725,7 +3725,7 @@ class BaseModelSqlv2 { toRead.push(pkValues); - if (toRead.length >= readChunkSize) { + if (toRead.length >= readChunkSize || i === updateDatas.length - 1) { const tempToRead = toRead.splice(0, toRead.length); const oldRecords = await this.list( {