Skip to content

Conversation

@h3n4l
Copy link
Member

@h3n4l h3n4l commented Jan 26, 2026

Summary

  • Implement 7 high-ROI MongoDB administrative methods prioritized by usage frequency
  • Lower-ROI methods remain as planned operations with fallback to mongosh

Implemented Methods

Index Management:

  • db.collection.createIndex(keys, options?) - Create a single index
  • db.collection.dropIndex(index) - Drop index by name or key spec
  • db.collection.dropIndexes() - Drop all indexes (except _id)

Collection Management:

  • db.collection.drop() - Drop a collection
  • db.collection.renameCollection(newName, dropTarget?) - Rename a collection

Database Management:

  • db.createCollection(name) - Create a new collection
  • db.dropDatabase() - Drop the current database

Not Implemented (Lower ROI)

These remain as planned operations with PlannedOperationError:

  • createIndexes (batch index creation)
  • stats(), serverStatus(), serverBuildInfo(), etc.
  • Collection size methods (dataSize, storageSize, etc.)

Test plan

  • All existing tests pass
  • New integration tests for each implemented method
  • Tests run on MongoDB 4.4, MongoDB 8.0, and DocumentDB
  • renameCollection tests run only on MongoDB (not supported by DocumentDB)

🤖 Generated with Claude Code

Add support for 7 commonly-used MongoDB administrative methods:

Index Management:
- db.collection.createIndex(keys, options?)
- db.collection.dropIndex(index)
- db.collection.dropIndexes()

Collection Management:
- db.collection.drop()
- db.collection.renameCollection(newName, dropTarget?)

Database Management:
- db.createCollection(name)
- db.dropDatabase()

Lower-ROI methods (stats, serverStatus, etc.) remain as planned
operations with PlannedOperationError for fallback to mongosh.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings January 26, 2026 07:42
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 the high-ROI subset of MongoDB administrative operations (indexes, collections, and database-level) in the translator and executor layers, with corresponding integration tests across MongoDB and DocumentDB. Lower-ROI admin methods remain planned-only with fallback via PlannedOperationError.

Changes:

  • Extend the translator with new operation types (OpCreateIndex, OpDropIndex, OpDropIndexes, OpDrop, OpCreateCollection, OpDropDatabase, OpRenameCollection) and argument extraction for the corresponding shell methods and db statements.
  • Add executor implementations for the new administrative operations, including index creation/deletion, collection creation/deletion/rename, and database drop, plus a MongoDB-only test runner helper.
  • Update the method registry and error tests to reflect the reduced set of planned-only methods, and add comprehensive integration tests for all implemented admin operations.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
internal/translator/visitor.go Routes new db statements and collection methods to the appropriate M3 administrative OpType values and extraction helpers.
internal/translator/types.go Introduces new OperationType values and fields on Operation for index and collection admin metadata (keys, names, rename flags), plus a placeholder IndexModel type.
internal/translator/method_registry.go Shrinks the planned-method registry to only lower-ROI administrative methods, removing entries for now-implemented admin operations.
internal/translator/database.go Adds argument extraction for db.createCollection(...), validating and storing the target collection name.
internal/translator/collection.go Implements argument extraction for createIndex, dropIndex, dropIndexes, and renameCollection, including validation and translation into Operation fields.
internal/testutil/container.go Adds RunOnMongoDBOnly helper to run tests on MongoDB instances while skipping DocumentDB (needed for renameCollection).
internal/executor/executor.go Wires new administrative OpTypes into the dispatcher and forwards them to dedicated admin executor functions.
internal/executor/admin.go Implements execution of index, collection, and database admin commands against the Go MongoDB driver, including helper functions for index key comparison.
error_test.go Adjusts planned-operation tests to use createIndexes instead of createIndex and updates method registry stats to the new planned-method count.
admin_test.go Adds integration tests for create/drop indexes, create/drop collection, drop database, and rename collection (with and without dropTarget), including multi-backend coverage and MongoDB-only scenarios.

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

h3n4l and others added 2 commits January 26, 2026 15:58
- createCollection(): reject options argument (not supported yet)
- dropIndexes(): reject array argument instead of silently dropping all
- createIndex(): reject unsupported options instead of ignoring them
- Remove unused IndexModels field and IndexModel type

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Address PR review feedback by implementing proper support instead of
rejecting unsupported features:

createCollection options:
- capped: boolean for capped collections
- size: size in bytes for capped collections
- max: max documents for capped collections
- validator: validation rules document
- validationLevel/validationAction: validation settings

createIndex options:
- unique: boolean for unique indexes
- sparse: boolean for sparse indexes
- expireAfterSeconds: TTL index support
- background: accepted but deprecated (no-op)

dropIndexes enhancements:
- Support array of index names to drop multiple specific indexes

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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

Copilot reviewed 11 out of 12 changed files in this pull request and generated 1 comment.


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

Address PR review comment about duplicate toInt64 helper by:
- Exporting ToInt64 and ToInt32 from translator/helpers.go
- Removing duplicate toInt64 from executor/admin.go
- Using translator.ToInt64 in executor for numeric comparisons

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@rebelice rebelice merged commit c296164 into main Jan 26, 2026
2 checks passed
@rebelice rebelice deleted the vk/d749-read-our-gomongo branch January 26, 2026 09:38
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