Skip to content

Commit

Permalink
fix(document): respect child schema minimize if toObject() is cal…
Browse files Browse the repository at this point in the history
…led without an explicit `minimize`

Fix #9405
  • Loading branch information
vkarpov15 committed Sep 10, 2020
1 parent 57a015a commit b018d2d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -3078,13 +3078,14 @@ Document.prototype.$toObject = function(options, json) {

// If options do not exist or is not an object, set it to empty object
options = utils.isPOJO(options) ? clone(options) : {};
options._calledWithOptions = options._calledWithOptions || clone(options);

if (!('flattenMaps' in options)) {
options.flattenMaps = defaultOptions.flattenMaps;
}

let _minimize;
if (options.minimize != null) {
if (options._calledWithOptions.minimize != null) {
_minimize = options.minimize;
} else if (defaultOptions.minimize != null) {
_minimize = defaultOptions.minimize;
Expand Down
2 changes: 0 additions & 2 deletions test/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,6 @@ describe('utils', function() {
assert.deepEqual(out.arr[0], { a: 42 });
assert.deepEqual(out.arr[1], {});
assert.deepEqual(out.arr[2], {});

return Promise.resolve();
});
});

Expand Down

0 comments on commit b018d2d

Please sign in to comment.