From 2373c07136629d302fd9182cd6186c30ca4afee2 Mon Sep 17 00:00:00 2001 From: Daniel Diaz <39510674+IslandRhythms@users.noreply.github.com> Date: Mon, 25 Jan 2021 10:28:35 -0500 Subject: [PATCH] fix: gh-8798 adding $__ in front of schema at line 1671 let all the toObject tests pass and fixed the maximum stack error --- lib/document.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/document.js b/lib/document.js index 498235955f..f7c83bceff 100644 --- a/lib/document.js +++ b/lib/document.js @@ -1668,7 +1668,7 @@ Document.prototype.$__path = function(path) { if (adhocType) { return adhocType; } - return this.schema.path(path); + return this.$__schema.path(path); }; /** @@ -3047,7 +3047,9 @@ Document.prototype.$__setSchema = function(schema) { for (const key of Object.keys(schema.virtuals)) { schema.virtuals[key]._applyDefaultGetters(); } - this.schema = schema; + if (schema.path('schema') == null) { + this.schema = schema; + } this.$__schema = schema; this[documentSchemaSymbol] = schema; };