Browse Source

fix(nocodb): revise mapAliasToColumn datetime logic & add comments

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

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

@ -472,6 +472,7 @@ export default class Model implements TableType {
.format('YYYY-MM-DD HH:mm:ss'); .format('YYYY-MM-DD HH:mm:ss');
} }
} else if (isSqlite) { } else if (isSqlite) {
// e.g. 2023-05-10T10:38:50.000Z -> 2023-05-10 10:38:50
val = dayjs val = dayjs
.utc(val) .utc(val)
.utcOffset(d.getTimezoneOffset(), true) .utcOffset(d.getTimezoneOffset(), true)
@ -485,23 +486,17 @@ export default class Model implements TableType {
.format('YYYY-MM-DD HH:mm:ssZ'); .format('YYYY-MM-DD HH:mm:ssZ');
} }
} else if (isMssql) { } else if (isMssql) {
// e.g. 2023-05-10T08:49:32.000Z -> 2023-05-10 08:49:32-08:00
val = dayjs val = dayjs
.utc(val) .utc(val)
.utcOffset(d.getTimezoneOffset(), false) .utcOffset(d.getTimezoneOffset(), false)
.format('YYYY-MM-DD HH:mm:ssZ'); .format('YYYY-MM-DD HH:mm:ssZ');
} }
} else { } else {
// External DB // External DB - convert to utc
if (isMySQL) { val = dayjs(val)
// convert to utc .utc()
val = dayjs(val).utc().format('YYYY-MM-DD HH:mm:ss'); .format(isMySQL ? 'YYYY-MM-DD HH:mm:ss' : 'YYYY-MM-DD HH:mm:ssZ');
} 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');
}
} }
} }
insertObj[sanitize(col.column_name)] = val; insertObj[sanitize(col.column_name)] = val;

Loading…
Cancel
Save