Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/drivers/node-mongodb-native/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const internalToObjectOptions = require('../../options').internalToObjectOptions
const stream = require('stream');
const util = require('util');

const formatToObjectOptions = Object.freeze({ ...internalToObjectOptions, copyTrustedSymbol: false });

/**
* A [node-mongodb-native](https://github.com/mongodb/node-mongodb-native) collection implementation.
*
Expand Down Expand Up @@ -384,7 +386,9 @@ function format(obj, sub, color, shell) {
}

const clone = require('../../helpers/clone');
let x = clone(obj, internalToObjectOptions);
// `sub` indicates `format()` was called recursively, so skip cloning because we already
// did a deep clone on the top-level object.
let x = sub ? obj : clone(obj, formatToObjectOptions);
const constructorName = getConstructorName(x);

if (constructorName === 'Binary') {
Expand Down
2 changes: 1 addition & 1 deletion lib/helpers/clone.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ function cloneObject(obj, options, isArrayChild) {
} else if (seen) {
seen.set(obj, ret);
}
if (trustedSymbol in obj) {
if (trustedSymbol in obj && options?.copyTrustedSymbol !== false) {
ret[trustedSymbol] = obj[trustedSymbol];
}

Expand Down
Loading