Browse Source

feat(nocodb): set time zone before insert / update (tbc)

pull/5601/head
Wing-Kam Wong 2 years ago
parent
commit
570a3f214e
  1. 16
      packages/nocodb-nest/src/db/BaseModelSqlv2.ts

16
packages/nocodb-nest/src/db/BaseModelSqlv2.ts

@ -1755,6 +1755,10 @@ class BaseModelSqlv2 {
let response;
// const driver = trx ? trx : this.dbDriver;
if (this.isPg) {
await this.dbDriver.raw(`SET TIME ZONE 'UTC'`);
}
const query = this.dbDriver(this.tnPath).insert(insertObj);
if ((this.isPg || this.isMssql) && this.model.primaryKey) {
query.returning(
@ -1889,6 +1893,10 @@ class BaseModelSqlv2 {
const prevData = await this.readByPk(id);
if (this.isPg) {
await this.dbDriver.raw(`SET TIME ZONE 'UTC'`);
}
const query = this.dbDriver(this.tnPath)
.update(updateObj)
.where(await this._wherePk(id));
@ -2122,6 +2130,10 @@ class BaseModelSqlv2 {
// refer : https://www.sqlite.org/limits.html
const chunkSize = this.isSqlite ? 10 : _chunkSize;
if (this.isPg) {
await this.dbDriver.raw(`SET TIME ZONE 'UTC'`);
}
const response =
this.isPg || this.isMssql
? await this.dbDriver
@ -2168,6 +2180,10 @@ class BaseModelSqlv2 {
updatePkValues.push(pkValues);
}
if (this.isPg) {
await this.dbDriver.raw(`SET TIME ZONE 'UTC'`);
}
transaction = await this.dbDriver.transaction();
for (const o of toBeUpdated) {

Loading…
Cancel
Save