Browse Source

fix(nocodb): pg timestamp with time zone

pull/5642/head
Wing-Kam Wong 2 years ago
parent
commit
8e6a440bb6
  1. 24
      packages/nocodb/src/db/BaseModelSqlv2.ts

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

@ -37,8 +37,8 @@ import {
COMPARISON_SUB_OPS, COMPARISON_SUB_OPS,
IS_WITHIN_COMPARISON_SUB_OPS, IS_WITHIN_COMPARISON_SUB_OPS,
} from '../models/Filter'; } from '../models/Filter';
import Noco from '../Noco' import Noco from '../Noco';
import { HANDLE_WEBHOOK } from '../services/hook-handler.service' import { HANDLE_WEBHOOK } from '../services/hook-handler.service';
import formulaQueryBuilderv2 from './formulav2/formulaQueryBuilderv2'; import formulaQueryBuilderv2 from './formulav2/formulaQueryBuilderv2';
import genRollupSelectv2 from './genRollupSelectv2'; import genRollupSelectv2 from './genRollupSelectv2';
import conditionV2 from './conditionV2'; import conditionV2 from './conditionV2';
@ -2206,7 +2206,9 @@ class BaseModelSqlv2 {
const updateDatas = raw const updateDatas = raw
? datas ? datas
: await Promise.all(datas.map((d) => this.model.mapAliasToColumn(d, this.clientMeta))); : await Promise.all(
datas.map((d) => this.model.mapAliasToColumn(d, this.clientMeta)),
);
const prevData = []; const prevData = [];
const newData = []; const newData = [];
@ -2564,7 +2566,6 @@ class BaseModelSqlv2 {
} }
private async handleHooks(hookName, prevData, newData, req): Promise<void> { private async handleHooks(hookName, prevData, newData, req): Promise<void> {
Noco.eventEmitter.emit(HANDLE_WEBHOOK, { Noco.eventEmitter.emit(HANDLE_WEBHOOK, {
hookName, hookName,
prevData, prevData,
@ -2573,8 +2574,8 @@ class BaseModelSqlv2 {
viewId: this.viewId, viewId: this.viewId,
modelId: this.model.id, modelId: this.model.id,
tnPath: this.tnPath, tnPath: this.tnPath,
}) });
/* /*
const view = await View.get(this.viewId); const view = await View.get(this.viewId);
@ -3259,11 +3260,6 @@ class BaseModelSqlv2 {
if (d) { if (d) {
for (const col of dateTimeColumns) { for (const col of dateTimeColumns) {
if (d[col.title]) { if (d[col.title]) {
if (col.dt === 'timestamp with time zone') {
// postgres - timezone already attached to input
// hence, skip it
continue;
}
if (this.isSqlite) { if (this.isSqlite) {
if (!col.cdf && !isXcdbBase) { if (!col.cdf && !isXcdbBase) {
// for external db, timezone already attached to input // for external db, timezone already attached to input
@ -3285,6 +3281,12 @@ class BaseModelSqlv2 {
} }
} }
if (col.dt === 'timestamp with time zone') {
// postgres - timezone already attached to input
// e.g. 2023-05-11 16:16:51+08:00
keepLocalTime = false;
}
if (d[col.title] instanceof Date) { if (d[col.title] instanceof Date) {
// e.g. MSSQL // e.g. MSSQL
// Wed May 10 2023 17:47:46 GMT+0800 (Hong Kong Standard Time) // Wed May 10 2023 17:47:46 GMT+0800 (Hong Kong Standard Time)

Loading…
Cancel
Save