mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
🎨 🔦 do not append isPostgreSQL to config
refs #6982 - we cannot add functions to nconf [ci skip]
This commit is contained in:
parent
0ae0a0b490
commit
34e48dc49a
3 changed files with 15 additions and 8 deletions
|
@ -2,6 +2,14 @@ var knex = require('knex'),
|
|||
config = require('../../config'),
|
||||
knexInstance;
|
||||
|
||||
function isPostgreSQL(client) {
|
||||
if (!client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return client === 'pg' || client === 'postgres' || client === 'postgresql';
|
||||
}
|
||||
|
||||
// @TODO:
|
||||
// - if you require this file before config file was loaded,
|
||||
// - then this file is cached and you have no chance to connect to the db anymore
|
||||
|
@ -10,11 +18,7 @@ function configure(dbConfig) {
|
|||
var client = dbConfig.client,
|
||||
pg;
|
||||
|
||||
dbConfig.isPostgreSQL = function () {
|
||||
return client === 'pg' || client === 'postgres' || client === 'postgresql';
|
||||
};
|
||||
|
||||
if (dbConfig.isPostgreSQL()) {
|
||||
if (isPostgreSQL(client)) {
|
||||
try {
|
||||
pg = require('pg');
|
||||
} catch (e) {
|
||||
|
@ -55,3 +59,4 @@ if (!knexInstance && config.get('database') && config.get('database').client) {
|
|||
}
|
||||
|
||||
module.exports = knexInstance;
|
||||
module.exports.isPostgreSQL = isPostgreSQL;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
var config = require('../../../../config'),
|
||||
models = require(config.get('paths').corePath + '/server/models'),
|
||||
api = require(config.get('paths').corePath + '/server/api'),
|
||||
db = require(config.get('paths').corePath + '/server/data/db/connection'),
|
||||
sequence = require(config.get('paths').corePath + '/server/utils/sequence'),
|
||||
moment = require('moment'),
|
||||
_ = require('lodash'),
|
||||
|
@ -43,7 +44,7 @@ module.exports = function transformDatesIntoUTC(options, logger) {
|
|||
return Promise.reject(new Error('skip'));
|
||||
}
|
||||
|
||||
if (config.get('database').isPostgreSQL()) {
|
||||
if (db.isPostgreSQL()) {
|
||||
_private.noOffset = true;
|
||||
} else if (config.get('database').client === 'mysql') {
|
||||
_private.noOffset = false;
|
||||
|
|
|
@ -9,6 +9,7 @@ var should = require('should'),
|
|||
configUtils = require('../utils/configUtils'),
|
||||
models = require('../../server/models'),
|
||||
api = require('../../server/api'),
|
||||
db = require('../../server/data/db/connection'),
|
||||
permissions = require('../../server/permissions'),
|
||||
notifications = require('../../server/api/notifications'),
|
||||
versioning = require('../../server/data/schema/versioning'),
|
||||
|
@ -967,9 +968,9 @@ describe('Fixtures', function () {
|
|||
migrationsSettingsValue;
|
||||
|
||||
beforeEach(function () {
|
||||
configUtils.config.database.isPostgreSQL = function () {
|
||||
sandbox.stub(db, 'isPostgreSQL', function isPostgreSQL() {
|
||||
return isPostgres;
|
||||
};
|
||||
});
|
||||
|
||||
sandbox.stub(Date.prototype, 'getTimezoneOffset', function () {
|
||||
return serverTimezoneOffset;
|
||||
|
|
Loading…
Add table
Reference in a new issue