From dcccb544f9ec24ad693c9e81fb4bcfbdbb7cc4e1 Mon Sep 17 00:00:00 2001 From: Fabio Di Stasio Date: Fri, 16 Apr 2021 18:48:56 +0200 Subject: [PATCH] fix(MySQL): invalid JavaScript datetime values not shown --- src/main/libs/clients/MySQLClient.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/libs/clients/MySQLClient.js b/src/main/libs/clients/MySQLClient.js index 98c4912c..4e10078a 100644 --- a/src/main/libs/clients/MySQLClient.js +++ b/src/main/libs/clients/MySQLClient.js @@ -104,8 +104,18 @@ export class MySQLClient extends AntaresCore { async connect () { if (!this._poolSize) this._connection = mysql.createConnection(this._params); - else - this._connection = mysql.createPool({ ...this._params, connectionLimit: this._poolSize }); + else { + this._connection = mysql.createPool({ + ...this._params, + connectionLimit: this._poolSize, + typeCast: (field, next) => { + if (field.type === 'DATETIME') + return field.string(); + else + return next(); + } + }); + } } /**