mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-27 22:49:56 -05:00
Merge pull request #4676 from jaswilli/pg-update
Update pg package and convert data to correct type
This commit is contained in:
commit
1b37ba5753
2 changed files with 21 additions and 1 deletions
|
@ -65,6 +65,25 @@ ConfigManager.prototype.init = function (rawConfig) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function configureDriver(client) {
|
||||||
|
var pg;
|
||||||
|
|
||||||
|
if (client === 'pg' || client === 'postgres' || client === 'postgresql') {
|
||||||
|
try {
|
||||||
|
pg = require('pg');
|
||||||
|
} catch (e) {
|
||||||
|
pg = require('pg.js');
|
||||||
|
}
|
||||||
|
|
||||||
|
// By default PostgreSQL returns data as strings along with an OID that identifies
|
||||||
|
// its type. We're setting the parser to convert OID 20 (int8) into a javascript
|
||||||
|
// integer.
|
||||||
|
pg.types.setTypeParser(20, function (val) {
|
||||||
|
return val === null ? null : parseInt(val, 10);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows you to set the config object.
|
* Allows you to set the config object.
|
||||||
* @param {Object} config Only accepts an object at the moment.
|
* @param {Object} config Only accepts an object at the moment.
|
||||||
|
@ -105,6 +124,7 @@ ConfigManager.prototype.set = function (config) {
|
||||||
(crypto.createHash('md5').update(packageInfo.version + Date.now()).digest('hex')).substring(0, 10);
|
(crypto.createHash('md5').update(packageInfo.version + Date.now()).digest('hex')).substring(0, 10);
|
||||||
|
|
||||||
if (!knexInstance && this._config.database && this._config.database.client) {
|
if (!knexInstance && this._config.database && this._config.database.client) {
|
||||||
|
configureDriver(this._config.database.client);
|
||||||
knexInstance = knex(this._config.database);
|
knexInstance = knex(this._config.database);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"mysql": "2.1.1",
|
"mysql": "2.1.1",
|
||||||
"pg.js": "3.6.2"
|
"pg": "4.1.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"blanket": "~1.1.6",
|
"blanket": "~1.1.6",
|
||||||
|
|
Loading…
Add table
Reference in a new issue