From bc215556155e6927551e39313cecba781f884660 Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Sun, 29 Jul 2018 17:14:28 -0400 Subject: [PATCH] fix(document): handle overwriting `$session` in `execPopulate()` Re: #6754 --- lib/document.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/document.js b/lib/document.js index f3f6c1dc0ba..f5ea5d253bd 100644 --- a/lib/document.js +++ b/lib/document.js @@ -2771,8 +2771,13 @@ Document.prototype.populate = function populate() { if (this.$session() != null) { const session = this.$session(); paths.forEach(path => { - path.options = path.options || {}; - path.options.session = session; + if (path.options == null) { + path.options = { session: session }; + return; + } + if (!('session' in path.options)) { + path.options.session = session; + } }); }