Skip to content

Commit b018d2d

Browse files
committed
fix(document): respect child schema minimize if toObject() is called without an explicit minimize
Fix #9405
1 parent 57a015a commit b018d2d

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

lib/document.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3078,13 +3078,14 @@ Document.prototype.$toObject = function(options, json) {
30783078

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

30823083
if (!('flattenMaps' in options)) {
30833084
options.flattenMaps = defaultOptions.flattenMaps;
30843085
}
30853086

30863087
let _minimize;
3087-
if (options.minimize != null) {
3088+
if (options._calledWithOptions.minimize != null) {
30883089
_minimize = options.minimize;
30893090
} else if (defaultOptions.minimize != null) {
30903091
_minimize = defaultOptions.minimize;

test/utils.test.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,6 @@ describe('utils', function() {
250250
assert.deepEqual(out.arr[0], { a: 42 });
251251
assert.deepEqual(out.arr[1], {});
252252
assert.deepEqual(out.arr[2], {});
253-
254-
return Promise.resolve();
255253
});
256254
});
257255

0 commit comments

Comments
 (0)