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. 9
      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

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

@ -303,9 +303,12 @@ abstract class BaseModel {
await this.validate(d);
}
const response = await this.dbDriver
.batchInsert(this.tn, data, 50)
.returning(this.pks?.[0]?.cn || '*');
const response = (this.dbDriver.client === 'pg' || this.dbDriver.client === 'mssql') ?
this.dbDriver
.batchInsert(this.tn, data, 50)
.returning(this.pks?.[0]?.cn || '*') :
this.dbDriver
.batchInsert(this.tn, data, 50);
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);
}
const response = await this.dbDriver
.batchInsert(this.tn, insertDatas, 50)
.returning(this.pks[0].cn);
const response = (this.dbDriver.client === 'pg' || this.dbDriver.client === 'mssql') ?
await this.dbDriver
.batchInsert(this.tn, insertDatas, 50)
.returning(this.pks[0].cn) :
await this.dbDriver
.batchInsert(this.tn, insertDatas, 50);
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
const chunkSize = this.isSqlite ? 10 : _chunkSize;
const response = await this.dbDriver
.batchInsert(this.model.table_name, insertDatas, chunkSize)
.returning(this.model.primaryKey?.column_name);
const response = (this.isPg || this.isMssql) ?
await this.dbDriver
.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);

Loading…
Cancel
Save