Browse Source

fix(nocodb): handle timestampz for pg

pull/5642/head
Wing-Kam Wong 2 years ago
parent
commit
7bfbf308d4
  1. 6
      packages/nocodb/src/models/Model.ts

6
packages/nocodb/src/models/Model.ts

@ -477,10 +477,13 @@ export default class Model implements TableType {
.utcOffset(d.getTimezoneOffset(), true)
.format('YYYY-MM-DD HH:mm:ss');
} else if (isPg) {
if (col.dt !== 'timestamp with time zone') {
// e.g. 2023-05-10T08:49:32.000Z -> 2023-05-10 08:49:32-08:00
val = dayjs
.utc(val)
.utcOffset(d.getTimezoneOffset(), true)
.format('YYYY-MM-DD HH:mm:ssZ');
}
} else if (isMssql) {
val = dayjs
.utc(val)
@ -492,6 +495,9 @@ export default class Model implements TableType {
if (isMySQL) {
// convert to utc
val = dayjs(val).utc().format('YYYY-MM-DD HH:mm:ss');
} else if (isPg) {
// convert to utc
val = dayjs(val).utc().format('YYYY-MM-DD HH:mm:ssZ');
} else {
// keep it as it is
val = dayjs(val).format('YYYY-MM-DD HH:mm:ssZ');

Loading…
Cancel
Save