Browse Source

refactor(nocodb): revise comments

pull/5719/head
Wing-Kam Wong 2 years ago
parent
commit
770c34c4d3
  1. 4
      packages/nocodb/src/db/formulav2/formulaQueryBuilderv2.ts
  2. 2
      packages/nocodb/src/models/Model.ts

4
packages/nocodb/src/db/formulav2/formulaQueryBuilderv2.ts

@ -541,6 +541,7 @@ async function _formulaQueryBuilder(
if (knex.clientType().startsWith('mysql')) {
aliasToColumn[col.id] = async (): Promise<any> => {
return {
// convert from DB timezone to UTC
builder: knex.raw(
`CONVERT_TZ(??, @@GLOBAL.time_zone, '+00:00')`,
[col.column_name],
@ -554,6 +555,7 @@ async function _formulaQueryBuilder(
) {
aliasToColumn[col.id] = async (): Promise<any> => {
return {
// convert from DB timezone to UTC
builder: knex
.raw(
`?? AT TIME ZONE CURRENT_SETTING('timezone') AT TIME ZONE 'UTC'`,
@ -566,7 +568,7 @@ async function _formulaQueryBuilder(
knex.clientType() === 'mssql' &&
col.dt !== 'datetimeoffset'
) {
// if there is no timezone info, convert to database timezone, then convert to UTC
// convert from DB timezone to UTC
aliasToColumn[col.id] = async (): Promise<any> => {
return {
builder: knex.raw(

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

@ -495,6 +495,7 @@ export default class Model implements TableType {
dayjs(val).utc().format('YYYY-MM-DD HH:mm:ss'),
]);
} else if (isSqlite) {
// convert to UTC
// e.g. 2022-01-01T10:00:00.000Z -> 2022-01-01 04:30:00+00:00
val = dayjs(val).utc().format('YYYY-MM-DD HH:mm:ssZ');
} else if (isPg) {
@ -505,6 +506,7 @@ export default class Model implements TableType {
dayjs(val).utc().format('YYYY-MM-DD HH:mm:ssZ'),
]);
} else if (isMssql) {
// convert ot UTC
// e.g. 2023-05-10T08:49:32.000Z -> 2023-05-10 08:49:32-08:00
// then convert to db timezone
val = knex.raw(

Loading…
Cancel
Save