@cubejs-backend/postgres-driver
Advanced tools
Comparing version 0.11.18 to 0.11.20
@@ -6,2 +6,13 @@ # Change Log | ||
## [0.11.20](https://github.com/cube-js/cube.js/compare/v0.11.19...v0.11.20) (2019-11-18) | ||
### Bug Fixes | ||
* Fix postgres driver timestamp parsing by using pg per-query type parser ([#269](https://github.com/cube-js/cube.js/issues/269)) Thanks to [@berndartmueller](https://github.com/berndartmueller)! ([458c0c9](https://github.com/cube-js/cube.js/commit/458c0c9)), closes [#265](https://github.com/cube-js/cube.js/issues/265) | ||
## [0.11.18](https://github.com/cube-js/cube.js/compare/v0.11.17...v0.11.18) (2019-11-09) | ||
@@ -8,0 +19,0 @@ |
const pg = require('pg'); | ||
const { types } = require('pg'); | ||
const moment = require('moment'); | ||
@@ -11,5 +12,6 @@ const BaseDriver = require('@cubejs-backend/query-orchestrator/driver/BaseDriver'); | ||
pg.types.setTypeParser(1114, str => moment.utc(str).format(moment.HTML5_FMT.DATETIME_LOCAL_MS)); | ||
pg.types.setTypeParser(1184, str => moment.utc(str).format(moment.HTML5_FMT.DATETIME_LOCAL_MS)); | ||
const timestampDataTypes = [1114, 1184]; | ||
const timestampTypeParser = val => moment.utc(val).format(moment.HTML5_FMT.DATETIME_LOCAL_MS); | ||
class PostgresDriver extends BaseDriver { | ||
@@ -53,3 +55,15 @@ constructor(config) { | ||
text: query, | ||
values: values || [] | ||
values: values || [], | ||
types: { | ||
getTypeParser: (dataType, format) => { | ||
const isTimestamp = timestampDataTypes.indexOf(dataType) > -1; | ||
let parser = types.getTypeParser(dataType, format); | ||
if (isTimestamp) { | ||
parser = timestampTypeParser; | ||
} | ||
return val => parser(val); | ||
}, | ||
}, | ||
}); | ||
@@ -56,0 +70,0 @@ return res && res.rows; |
@@ -5,3 +5,3 @@ { | ||
"author": "Statsbot, Inc.", | ||
"version": "0.11.18", | ||
"version": "0.11.20", | ||
"repository": { | ||
@@ -22,3 +22,3 @@ "type": "git", | ||
"moment": "^2.24.0", | ||
"pg": "^7.8.0" | ||
"pg": "^7.10.0" | ||
}, | ||
@@ -32,3 +32,3 @@ "license": "Apache-2.0", | ||
}, | ||
"gitHead": "ce40708f8012e5f6de475d74f4841501caa0d998" | ||
"gitHead": "79670a0942c4fe03db87ba63a5ba2f33fcbd7bd1" | ||
} |
24739
91
Updatedpg@^7.10.0