From 5c3405eceb086e2c621f1a8f5aa541d2756163bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Mon, 29 Apr 2019 09:39:20 +0200 Subject: [PATCH] Add support for Node.js 12.x - Fix code to pass all tests on Node.js 12 - Add Node.js 12 to the list of Travis CI platforms --- .travis.yml | 1 + lib/date-string.js | 7 +++++++ lib/model-utils.js | 2 ++ lib/model.js | 7 +++++++ 4 files changed, 17 insertions(+) diff --git a/.travis.yml b/.travis.yml index 2cf1e4a1..70df5221 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,5 +3,6 @@ language: node_js node_js: - "8" - "10" + - "12" after_success: npm run coverage diff --git a/lib/date-string.js b/lib/date-string.js index 905dc5ad..09a0bee1 100644 --- a/lib/date-string.js +++ b/lib/date-string.js @@ -97,3 +97,10 @@ DateString.prototype.inspect = function(depth, options) { _date: this._date, }); }; + +if (inspect.custom) { + // Node.js 12+ no longer recognizes "inspect" method, + // it uses "inspect.custom" symbol as the key instead + // TODO(semver-major) always use the symbol key only (requires Node.js 8+). + DateString.prototype[inspect.custom] = DateString.prototype.inspect; +} diff --git a/lib/model-utils.js b/lib/model-utils.js index a83974f6..da5c3286 100644 --- a/lib/model-utils.js +++ b/lib/model-utils.js @@ -389,6 +389,8 @@ ModelUtils._coerce = function(where, options) { self._coerce(clauses[k], options); } + where[p] = clauses; + continue; } let DataType = props[p] && props[p].type; diff --git a/lib/model.js b/lib/model.js index 5b2bc33e..de874e2b 100644 --- a/lib/model.js +++ b/lib/model.js @@ -637,6 +637,13 @@ ModelBaseClass.prototype.inspect = function(depth) { }); }; +if (util.inspect.custom) { + // Node.js 12+ no longer recognizes "inspect" method, + // it uses "inspect.custom" symbol as the key instead + // TODO(semver-major) always use the symbol key only (requires Node.js 8+). + ModelBaseClass.prototype[util.inspect.custom] = ModelBaseClass.prototype.inspect; +} + /** * * @param {String} anotherClass could be string or class. Name of the class or the class itself