Skip to content

Commit f1346da

Browse files
committed
fix: Postgres driver with redis in non UTC timezone returns timezone shifted results
1 parent 84ea78a commit f1346da

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

packages/cubejs-postgres-driver/driver/PostgresDriver.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1+
const pg = require('pg');
2+
const moment = require('moment');
13
const BaseDriver = require('@cubejs-backend/query-orchestrator/driver/BaseDriver');
2-
const { Pool } = require('pg');
4+
5+
const { Pool } = pg;
36

47
const GenericTypeToPostgres = {
58
string: 'text'
69
};
710

11+
pg.types.setTypeParser(1114, str => moment.utc(str).format(moment.HTML5_FMT.DATETIME_LOCAL_MS));
12+
pg.types.setTypeParser(1184, str => moment.utc(str).format(moment.HTML5_FMT.DATETIME_LOCAL_MS));
13+
814
class PostgresDriver extends BaseDriver {
915
constructor(config) {
1016
super();

packages/cubejs-postgres-driver/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
},
1313
"dependencies": {
1414
"@cubejs-backend/query-orchestrator": "^0.11.0",
15+
"moment": "^2.24.0",
1516
"pg": "^7.8.0"
1617
},
1718
"license": "Apache-2.0",

0 commit comments

Comments
 (0)