Skip to content

Conversation

@Anemy
Copy link
Member

@Anemy Anemy commented Nov 13, 2025

MONGOSH-2486

Description

Adds LegacyJavaUUID, LegacyCSharpUUID, and LegacyPythonUUID helpers to the query-parser, shell-bson-parser, and mongodb-constants. These are ways for folks to pass a UUID string in the canonical form 00112233-4455-6677-8899-aabbccddeeff and have it encoded how the various legacy implementations did it. See the short history of UUIDs for more info.

In the next ticket, COMPASS-9690, we'll be adding this to Compass and providing a setting to customize how we're rendering the Binary subtype 3. We won't be adding that in mongosh, we'll keep showing the formatBinary.createFromBase64('Y7mFuOjdS9qQh+RALxo/9g==', 3).

https://www.mongodb.com/docs/languages/python/pymongo-driver/current/data-formats/uuid/#a-short-history-of-mongodb-uuids
Brief: UUID Support in Compass & Mongosh

LegacyJavaUUID: function (u: any) {
if (u === undefined) {
// Generate a new UUID and format it.
u = new bson.UUID().toHexString();
Copy link
Member Author

@Anemy Anemy Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chatting with @nbbeeken I think we were thinking of throwing an error here instead. This is when someone writes new LegacyJavaUUID() without a string in the quotes. Currently UUID creates a new UUID so I had initially written it to also generate a new UUID (of subtype 3).
Any other opinions on if it we should throw an error or allow it? I'll add an error throw otherwise. I'll ask Betsy on it too.

snippet: "LegacyPythonUUID('${1:uuid}')",
},
{
name: 'UUID',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously UUID didn't show up in Compass' autocomplete. I'm thinking it was just missing. This will make it start showing up:

Image

value: 'LegacyJavaUUID',
label: 'LegacyJavaUUID',
score: 1,
meta: 'bson-legacy-uuid',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The meta here will make it into Compass' autocompleter:

Image

@Anemy Anemy requested a review from nbbeeken November 13, 2025 23:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants