Skip to content

Commit

Permalink
Merge pull request TryGhost#6637 from ErisDS/knex-config
Browse files Browse the repository at this point in the history
Disable knex useNullAsDefault warning
  • Loading branch information
jaswilli committed Mar 24, 2016
2 parents a8fc296 + 8c74f55 commit e72dddb
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions core/server/data/db/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ var knex = require('knex'),
dbConfig = config.database,
knexInstance;

function configureDriver(client) {
var pg;
function configure(dbConfig) {
var client = dbConfig.client,
pg;

if (client === 'pg' || client === 'postgres' || client === 'postgresql') {
try {
Expand All @@ -20,11 +21,16 @@ function configureDriver(client) {
return val === null ? null : parseInt(val, 10);
});
}

if (client === 'sqlite3') {
dbConfig.useNullAsDefault = false;
}

return dbConfig;
}

if (!knexInstance && dbConfig && dbConfig.client) {
configureDriver(dbConfig.client);
knexInstance = knex(dbConfig);
knexInstance = knex(configure(dbConfig));
}

module.exports = knexInstance;

0 comments on commit e72dddb

Please sign in to comment.