Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mongodb/MongoShellLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ FALSE: 'false';
NULL: 'null';
GET_COLLECTION: 'getCollection';
GET_COLLECTION_NAMES: 'getCollectionNames';
GET_COLLECTION_INFOS: 'getCollectionInfos';

// Helper function names (recognized as distinct tokens)
OBJECT_ID: 'ObjectId';
Expand Down
8 changes: 5 additions & 3 deletions mongodb/MongoShellParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ shellCommand
| SHOW COLLECTIONS # showCollections
;

// Database statements: db.collection.method(...) or db.getCollectionNames()
// Database statements: db.collection.method(...) or db.getCollectionNames() or db.getCollectionInfos()
dbStatement
: DB DOT GET_COLLECTION_NAMES LPAREN RPAREN methodChain? # getCollectionNames
| DB collectionAccess methodChain # collectionOperation
: DB DOT GET_COLLECTION_NAMES LPAREN RPAREN methodChain? # getCollectionNames
| DB DOT GET_COLLECTION_INFOS LPAREN arguments? RPAREN methodChain? # getCollectionInfos
| DB collectionAccess methodChain # collectionOperation
;

// Collection access patterns
Expand Down Expand Up @@ -239,6 +240,7 @@ identifier
| PROJECT
| GET_COLLECTION
| GET_COLLECTION_NAMES
| GET_COLLECTION_INFOS
| OBJECT_ID
| ISO_DATE
| DATE
Expand Down
572 changes: 291 additions & 281 deletions mongodb/mongoshell_lexer.go

Large diffs are not rendered by default.

1,123 changes: 655 additions & 468 deletions mongodb/mongoshell_parser.go

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions mongodb/mongoshellparser_base_listener.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions mongodb/mongoshellparser_base_visitor.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions mongodb/mongoshellparser_listener.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions mongodb/mongoshellparser_visitor.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions mongodb/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ func TestCollectionAccess(t *testing.T) {
`db["user-logs"].find()`,
`db.getCollection("my.collection").find()`,
`db.getCollectionNames()`,
`db.getCollectionInfos()`,
`db.getCollectionInfos({ name: "users" })`,
`db.getCollectionInfos({}, { nameOnly: true })`,
}

for _, tc := range tests {
Expand Down
Loading