Skip to content

Commit 76308b5

Browse files
h3n4lclaude
andauthored
feat(mongodb): add db.getCollectionInfos() support (#51)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 8ac2a65 commit 76308b5

9 files changed

Lines changed: 974 additions & 752 deletions

mongodb/MongoShellLexer.g4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ FALSE: 'false';
1717
NULL: 'null';
1818
GET_COLLECTION: 'getCollection';
1919
GET_COLLECTION_NAMES: 'getCollectionNames';
20+
GET_COLLECTION_INFOS: 'getCollectionInfos';
2021

2122
// Helper function names (recognized as distinct tokens)
2223
OBJECT_ID: 'ObjectId';

mongodb/MongoShellParser.g4

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@ shellCommand
3232
| SHOW COLLECTIONS # showCollections
3333
;
3434

35-
// Database statements: db.collection.method(...) or db.getCollectionNames()
35+
// Database statements: db.collection.method(...) or db.getCollectionNames() or db.getCollectionInfos()
3636
dbStatement
37-
: DB DOT GET_COLLECTION_NAMES LPAREN RPAREN methodChain? # getCollectionNames
38-
| DB collectionAccess methodChain # collectionOperation
37+
: DB DOT GET_COLLECTION_NAMES LPAREN RPAREN methodChain? # getCollectionNames
38+
| DB DOT GET_COLLECTION_INFOS LPAREN arguments? RPAREN methodChain? # getCollectionInfos
39+
| DB collectionAccess methodChain # collectionOperation
3940
;
4041

4142
// Collection access patterns
@@ -239,6 +240,7 @@ identifier
239240
| PROJECT
240241
| GET_COLLECTION
241242
| GET_COLLECTION_NAMES
243+
| GET_COLLECTION_INFOS
242244
| OBJECT_ID
243245
| ISO_DATE
244246
| DATE

mongodb/mongoshell_lexer.go

Lines changed: 291 additions & 281 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mongodb/mongoshell_parser.go

Lines changed: 655 additions & 468 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mongodb/mongoshellparser_base_listener.go

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mongodb/mongoshellparser_base_visitor.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mongodb/mongoshellparser_listener.go

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mongodb/mongoshellparser_visitor.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mongodb/parser_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ func TestCollectionAccess(t *testing.T) {
149149
`db["user-logs"].find()`,
150150
`db.getCollection("my.collection").find()`,
151151
`db.getCollectionNames()`,
152+
`db.getCollectionInfos()`,
153+
`db.getCollectionInfos({ name: "users" })`,
154+
`db.getCollectionInfos({}, { nameOnly: true })`,
152155
}
153156

154157
for _, tc := range tests {

0 commit comments

Comments
 (0)