From ea68512c7e3037f5d608dd3d0f6262446a0c2dab Mon Sep 17 00:00:00 2001 From: Dragory Date: Sun, 5 Aug 2018 00:45:54 +0300 Subject: [PATCH] =?UTF-8?q?knexfile:=20fix=20issue=20with=20null=C3=83=20d?= =?UTF-8?q?ates?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- knexfile.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/knexfile.js b/knexfile.js index 7cc8d093..0a4f0a43 100644 --- a/knexfile.js +++ b/knexfile.js @@ -17,7 +17,8 @@ module.exports = { dateStrings: true, typeCast(field, next) { if (field.type === 'DATETIME') { - return moment(field.string()).format('YYYY-MM-DD HH:mm:ss'); + const val = field.string(); + return val != null ? moment(val).format('YYYY-MM-DD HH:mm:ss') : null; } return next();