Skip to content

Conversation

@h3n4l
Copy link
Member

@h3n4l h3n4l commented Jan 19, 2026

Summary

Implement Milestone 1 read operations for the MongoDB parser as defined in the Gomongo milestone design:

  • Add countDocuments(filter?, options?) - count documents matching a filter
  • Add estimatedDocumentCount(options?) - fast estimated count using metadata
  • Add distinct(field, query?, options?) - find distinct values for a field
  • Add aggregate(pipeline, options?) - aggregation pipeline support
  • Add getIndexes() - get all indexes on a collection
  • Add cursor.count() - cursor modifier to return count

Also includes:

  • Proper error handling for new keyword with helpful error message via NotifyErrorListeners
  • Reorganized test files by collection method (collection-*.js) for better maintainability

Test plan

  • Run make build to regenerate parser
  • Run make test to verify all tests pass
  • Verify new collection method tests pass (collection-find.js, collection-aggregate.js, etc.)
  • Verify new ObjectId() produces helpful error message

🤖 Generated with Claude Code

Add support for Milestone 1 read operations, utility commands, and aggregation:

Collection methods:
- countDocuments(filter?, options?)
- estimatedDocumentCount(options?)
- distinct(field, query?, options?)
- aggregate(pipeline, options?)
- getIndexes()

Cursor modifiers:
- count()

Improvements:
- Add 'new' keyword error handling with helpful message via NotifyErrorListeners
- Reorganize test files by collection method (collection-*.js)
- Remove redundant test files covered by new structure

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Copilot AI review requested due to automatic review settings January 19, 2026 09:59
@h3n4l h3n4l merged commit 7f65a06 into main Jan 19, 2026
10 checks passed
@h3n4l h3n4l deleted the vk/0c2e-mongodb-parser-m branch January 19, 2026 10:01
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 PR implements Milestone 1 read operations for the MongoDB parser, adding support for advanced query methods (countDocuments, estimatedDocumentCount, distinct, aggregate, getIndexes) and the cursor count() modifier. The PR also reorganizes tests from inline test functions to separate example JavaScript files for better maintainability, and improves error handling for the 'new' keyword usage.

Changes:

  • Added 6 new collection methods: countDocuments, estimatedDocumentCount, distinct, aggregate, getIndexes, and cursor count()
  • Improved error handling for 'new' keyword with helpful error messages via NotifyErrorListeners
  • Reorganized tests from inline Go test functions to separate .js example files by collection method

Reviewed changes

Copilot reviewed 18 out of 19 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
mongodb/MongoShellParser.g4 Added grammar rules for new collection methods and consolidated 'new' keyword error handling
mongodb/MongoShellLexer.g4 Added tokens for new collection methods and count cursor modifier
mongodb/mongoshell_parser.go Generated parser code with new methods and updated rule indices
mongodb/mongoshellparser_visitor.go Generated visitor interfaces for new method contexts
mongodb/mongoshellparser_listener.go Generated listener interfaces for new method contexts
mongodb/mongoshellparser_base_visitor.go Generated base visitor implementations
mongodb/mongoshellparser_base_listener.go Generated base listener implementations
mongodb/parser_test.go Removed inline tests, simplified to use file-based tests, updated error message assertion
mongodb/examples/collection-*.js New example files testing each collection method comprehensively
mongodb/examples/find_operations.js Removed (replaced by collection-find.js)
mongodb/examples/cursor_modifiers.js Removed (integrated into collection-find.js)
mongodb/examples/collection_access.js Removed (distributed across new example files)

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

}
p.ExitRule()
return localctx
goto errorExit // Trick to prevent compiler error if the label is not used
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

This statement is unreachable.

Suggested change
goto errorExit // Trick to prevent compiler error if the label is not used

Copilot uses AI. Check for mistakes.
}
p.ExitRule()
return localctx
goto errorExit // Trick to prevent compiler error if the label is not used
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

This statement is unreachable.

Copilot uses AI. Check for mistakes.
}
p.ExitRule()
return localctx
goto errorExit // Trick to prevent compiler error if the label is not used
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

This statement is unreachable.

Suggested change
goto errorExit // Trick to prevent compiler error if the label is not used

Copilot uses AI. Check for mistakes.
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