Browse Source

fix: reduce batch size in sqlite to avoid `too many SQL variables` error

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/2197/head
Pranav C 2 years ago
parent
commit
1a0632b0dc
  1. 14
      packages/nocodb/src/lib/dataMapper/lib/sql/BaseModelSqlv2.ts

14
packages/nocodb/src/lib/dataMapper/lib/sql/BaseModelSqlv2.ts

@ -1528,8 +1528,13 @@ class BaseModelSqlv2 {
await this.validate(data);
}
// fallbacks to `10` if database client is sqlite
// to avoid `too many SQL variables` error
// refer : https://www.sqlite.org/limits.html
const chunkSize = this.isSqlite ? 10 : 50;
const response = await this.dbDriver
.batchInsert(this.model.table_name, insertDatas, 50)
.batchInsert(this.model.table_name, insertDatas, chunkSize)
.returning(this.model.primaryKey?.column_name);
// await this.afterInsertb(insertDatas, null);
@ -1834,7 +1839,12 @@ class BaseModelSqlv2 {
if (!validate) continue;
const { func, msg } = validate;
for (let j = 0; j < func.length; ++j) {
const fn = typeof func[j] === 'string' ? (customValidators[func[j]] ? customValidators[func[j]] : Validator[func[j]]) : func[j];
const fn =
typeof func[j] === 'string'
? customValidators[func[j]]
? customValidators[func[j]]
: Validator[func[j]]
: func[j];
const arg =
typeof func[j] === 'string' ? columns[cn] + '' : columns[cn];
if (

Loading…
Cancel
Save