fix(mongodb): make method arguments optional where mongosh allows empty calls#54
Merged
fix(mongodb): make method arguments optional where mongosh allows empty calls#54
Conversation
…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>
There was a problem hiding this comment.
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()andfindOne()to accept both filter and projection arguments (usingarguments?instead ofargument?) - Changed
aggregate()to allow empty pipeline calls - Made cursor method arguments optional for
sort,collation,comment,hint,max,min,readConcern,returnKey,showRecordId, andprojection
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.
rebelice
approved these changes
Jan 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
find/findOneto support both filter and projection arguments (arguments?instead ofargument?)aggregateto allow empty pipeline calls likedb.coll.aggregate()sort,collation,comment,hint,max,min,readConcern,returnKey,showRecordId,projection) to accept empty argument callsTest plan
cursor-optional-args.jscovering empty argument callsmongosh "mongodb://...")🤖 Generated with Claude Code