Browse Source

fix: sqlite issues

pull/9788/head
DarkPhoenix2704 2 weeks ago
parent
commit
e8db699a92
No known key found for this signature in database
GPG Key ID: 3F76B10622A07849
  1. 22
      packages/nocodb/src/db/BaseModelSqlv2.ts

22
packages/nocodb/src/db/BaseModelSqlv2.ts

@ -5326,8 +5326,6 @@ class BaseModelSqlv2 {
}
}
trx = await this.dbDriver.transaction();
// Check which records with PKs exist in the database
const existingRecords = await this.chunkList({
pks: dataWithPks.map((v) => v.pk),
@ -5349,20 +5347,18 @@ class BaseModelSqlv2 {
}
}
trx = await this.dbDriver.transaction();
const updatedPks = [];
if (toUpdate.length > 0) {
const pks = [];
for (const data of toUpdate) {
if (!raw) await this.validate(data, columns);
const pkValues = this.extractPksValues(data);
pks.push(pkValues);
updatedPks.push(pkValues);
const wherePk = await this._wherePk(pkValues, true);
await trx(this.tnPath).update(data).where(wherePk);
}
const updatedRecords = await this.chunkList({
pks,
});
updatedDatas.push(...updatedRecords);
}
if (toInsert.length > 0) {
@ -5420,12 +5416,16 @@ class BaseModelSqlv2 {
await trx.raw('SET foreign_key_checks = 1;');
}
}
insertedDatas.push(...responses);
}
await trx.commit();
const updatedRecords = await this.chunkList({
pks: updatedPks,
});
updatedDatas.push(...updatedRecords);
const insertedDataList =
insertedDatas.length > 0
? await this.chunkList({
@ -5501,7 +5501,7 @@ class BaseModelSqlv2 {
) {
const { allowSystemColumn } = params;
const cols = columns || (await this.model.getColumns(this.context));
let insertObj = {};
const insertObj = {};
for (let i = 0; i < cols.length; ++i) {
const col = cols[i];

Loading…
Cancel
Save