Skip to content

Conversation

@h3n4l
Copy link
Member

@h3n4l h3n4l commented Jan 21, 2026

Summary

  • Fix find/findOne to support both filter and projection arguments (arguments? instead of argument?)
  • Fix aggregate to allow empty pipeline calls like db.coll.aggregate()
  • Fix cursor methods (sort, collation, comment, hint, max, min, readConcern, returnKey, showRecordId, projection) to accept empty argument calls

Test plan

  • All 307 existing tests pass
  • Added new test file cursor-optional-args.js covering empty argument calls
  • Verified against local mongosh instance (mongosh "mongodb://...")

🤖 Generated with Claude Code

…ty calls

Several mongosh methods can be called with no arguments, but the parser
was requiring arguments. This fixes the grammar to match actual mongosh
behavior:

- find/findOne: support filter + projection args (arguments?)
- aggregate: allow empty pipeline (arguments?)
- Cursor methods: sort, collation, comment, hint, max, min, readConcern,
  returnKey, showRecordId, projection - all accept empty calls

Verified against local mongosh instance.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings January 21, 2026 02:41
@h3n4l h3n4l enabled auto-merge (squash) January 21, 2026 02:47
Copy link

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 pull request updates the MongoDB shell parser grammar to allow optional arguments for several methods where mongosh permits empty calls. The changes make the parser more permissive to match mongosh's actual behavior.

Changes:

  • Modified find() and findOne() to accept both filter and projection arguments (using arguments? instead of argument?)
  • Changed aggregate() to allow empty pipeline calls
  • Made cursor method arguments optional for sort, collation, comment, hint, max, min, readConcern, returnKey, showRecordId, and projection

Reviewed changes

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

File Description
mongodb/MongoShellParser.g4 Updated grammar rules to make method arguments optional where mongosh allows empty calls
mongodb/examples/cursor-optional-args.js Added test file demonstrating the newly supported empty argument syntax

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

@h3n4l h3n4l merged commit 6987049 into main Jan 21, 2026
12 checks passed
@h3n4l h3n4l deleted the fix/mongodb-optional-args branch January 21, 2026 03:02
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.

3 participants