From e3fcd882f29c2dc278cb8b665ce2abba89baffb2 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Thu, 6 Nov 2025 09:20:22 -0500 Subject: [PATCH] fix(shell-bson): ObjectId constructor compatibility with bson 7.x This is a breaking change in the 7.x bson package that we should hide from mongosh users. --- packages/shell-bson/src/shell-bson.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/shell-bson/src/shell-bson.ts b/packages/shell-bson/src/shell-bson.ts index fcdedc39f..354a91d6c 100644 --- a/packages/shell-bson/src/shell-bson.ts +++ b/packages/shell-bson/src/shell-bson.ts @@ -180,6 +180,7 @@ export function constructShellBson< [[undefined, 'string', 'number', 'object']], 'ObjectId' ); + if (typeof id === 'number') return bson.ObjectId.createFromTime(id); return new bson.ObjectId(id); }, pickWithExactKeyMatch(bson.ObjectId, ['prototype', 'cacheHexString', 'generate', 'createFromTime', 'createFromHexString', 'createFromBase64', 'isValid'])),