From 8c74f55b363a3b89d26e16b03a456f297730e0e5 Mon Sep 17 00:00:00 2001 From: Hannah Wolfe Date: Thu, 24 Mar 2016 12:49:06 +0000 Subject: [PATCH] Disable knex useNullAsDefault warning refs #6623 - automatically set useNullAsDefault to false for sqlite3 so that we don't get a warning - we should *not* be relying on the behaviour of interpretting undefined anywhere, so it is correct that an error should be output if this happens so that we can fix the bad behaviour --- core/server/data/db/connection.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/core/server/data/db/connection.js b/core/server/data/db/connection.js index 065967902b..d70c782b89 100644 --- a/core/server/data/db/connection.js +++ b/core/server/data/db/connection.js @@ -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 { @@ -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;