From 70b3d219abcc33e17c711de2b9031f654bd6cc1a 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 9cc22b70..ed11b496 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,5 +4,6 @@ node_js: - "6" - "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 9e8f9698..5abd9715 100644 --- a/lib/model-utils.js +++ b/lib/model-utils.js @@ -385,6 +385,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