Browse Source

feat(nocodb): handle datetime in formula aliasToColumn

pull/5659/head
Wing-Kam Wong 2 years ago
parent
commit
2487953610
  1. 27
      packages/nocodb/src/db/formulav2/formulaQueryBuilderv2.ts

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

@ -537,6 +537,33 @@ async function _formulaQueryBuilder(
}; };
}; };
break; break;
case UITypes.DateTime:
if (knex.clientType().startsWith('mysql')) {
aliasToColumn[col.id] = async (): Promise<any> => {
return {
builder: knex.raw(
`CONVERT_TZ(??, @@GLOBAL.time_zone, '+00:00')`,
[col.column_name],
),
};
};
} else if (
knex.clientType() === 'pg' &&
col.dt !== 'timestamp with time zone'
) {
aliasToColumn[col.id] = async (): Promise<any> => {
return {
builder: knex.raw(
`?? AT TIME ZONE CURRENT_SETTING('timezone') AT TIME ZONE 'UTC'`,
[col.column_name],
),
};
};
} else {
aliasToColumn[col.id] = () =>
Promise.resolve({ builder: col.column_name });
}
break;
default: default:
aliasToColumn[col.id] = () => aliasToColumn[col.id] = () =>
Promise.resolve({ builder: col.column_name }); Promise.resolve({ builder: col.column_name });

Loading…
Cancel
Save