Browse Source

fix: use returning only for pg and mssql

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/4280/head
mertmit 2 years ago
parent
commit
4c6c46bcc9
  1. 11
      packages/nocodb/src/lib/db/sql-data-mapper/lib/BaseModel.ts
  2. 9
      packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSql.ts
  3. 9
      packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts

11
packages/nocodb/src/lib/db/sql-data-mapper/lib/BaseModel.ts

@ -302,10 +302,13 @@ abstract class BaseModel {
for (const d of data) { for (const d of data) {
await this.validate(d); await this.validate(d);
} }
const response = await this.dbDriver const response = (this.dbDriver.client === 'pg' || this.dbDriver.client === 'mssql') ?
.batchInsert(this.tn, data, 50) this.dbDriver
.returning(this.pks?.[0]?.cn || '*'); .batchInsert(this.tn, data, 50)
.returning(this.pks?.[0]?.cn || '*') :
this.dbDriver
.batchInsert(this.tn, data, 50);
await this.afterInsertb(data); await this.afterInsertb(data);

9
packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSql.ts

@ -608,9 +608,12 @@ class BaseModelSql extends BaseModel {
await this.validate(d1); await this.validate(d1);
} }
const response = await this.dbDriver const response = (this.dbDriver.client === 'pg' || this.dbDriver.client === 'mssql') ?
.batchInsert(this.tn, insertDatas, 50) await this.dbDriver
.returning(this.pks[0].cn); .batchInsert(this.tn, insertDatas, 50)
.returning(this.pks[0].cn) :
await this.dbDriver
.batchInsert(this.tn, insertDatas, 50);
await this.afterInsertb(insertDatas, null); await this.afterInsertb(insertDatas, null);

9
packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts

@ -1826,9 +1826,12 @@ class BaseModelSqlv2 {
// refer : https://www.sqlite.org/limits.html // refer : https://www.sqlite.org/limits.html
const chunkSize = this.isSqlite ? 10 : _chunkSize; const chunkSize = this.isSqlite ? 10 : _chunkSize;
const response = await this.dbDriver const response = (this.isPg || this.isMssql) ?
.batchInsert(this.model.table_name, insertDatas, chunkSize) await this.dbDriver
.returning(this.model.primaryKey?.column_name); .batchInsert(this.model.table_name, insertDatas, chunkSize)
.returning(this.model.primaryKey?.column_name) :
await this.dbDriver
.batchInsert(this.model.table_name, insertDatas, chunkSize);
await this.afterBulkInsert(insertDatas, this.dbDriver, cookie); await this.afterBulkInsert(insertDatas, this.dbDriver, cookie);

Loading…
Cancel
Save