Skip to content

Conversation

@Anemy
Copy link
Member

@Anemy Anemy commented Nov 15, 2025

COMPASS-10077

We had similar functionality in Compass a long time ago. I was looking at NumberLong(number > Max js int) and had this as a drive by so I figured I'd add it in a separate pr. If folks feel this isn't needed please let me know! Happy to close without merging.

object.id.query.fix.mp4

@Anemy Anemy requested a review from a team as a code owner November 15, 2025 00:22
@Anemy Anemy requested review from Copilot and gribnoysup November 15, 2025 00:22
@github-actions github-actions bot added the feat label Nov 15, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds functionality to automatically wrap pasted MongoDB ObjectIds with the proper query syntax. When a user pastes a 24-character hexadecimal ObjectId enclosed in curly braces (e.g., {578cfb38d5021e616087f53f}), the code now transforms it into a valid query format: { _id: ObjectId("578cfb38d5021e616087f53f") }.

Key changes:

  • Refactored the lenientlyFixQuery function to separate concerns into distinct helper functions
  • Added ObjectId detection and wrapping functionality
  • Improved code organization by extracting brace-escaping logic into its own function

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/compass-query-bar/src/query/leniently-fix-query.ts Refactored query fixing logic into separate functions and added ObjectId detection/wrapping
packages/compass-query-bar/src/query/leniently-fix-query.spec.ts Added comprehensive test cases for ObjectId pasting scenarios

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants