Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

lerouxb
Copy link
Contributor

@lerouxb lerouxb commented May 29, 2025

In addition to now lazy loading mongodb-ts-autocomplete, I previously forgot that the tests won't run for the new one unless you specify USE_NEW_AUTOCOMPLETE=true.

I fixed the tests now, but it does highlight some subtle changes between the new design and the old. Notably with the typescript way we only autocomplete for collections that are known to exist, so we can't autocomplete db.doesNotExistYet.insertOne( which is a valid use case for creating a new collection. In probably all other instances this new behaviour is arguably an improvement because if you typed out a collection name that does not exist then not getting autocomplete results is a powerful hint that you made a mistake.

Furthermore the new autocomplete does not take into account server version or capabilities (yet), so things like getShardDistribution autocompletes for every collection and db.watch autocomplete for every database.

And finally mongodb-ts-autocomplete does not support connections that aren't connected. It expects objects like db to be real and to be able to list databases and collections and get collection schemas. We can probably tweak it in future so you can get a partial experience, but for now I'm not calling it in the noDb scenario. It is still feature flagged after all.

}

// mongodb-ts-autocomplete requires a connection and a schema
if (this.shellCliOptions.nodb) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

--nodb does not directly imply that db is inaccessible, e.g. you can do

$ mongosh --nodb
[...]
> db = connect(process.env.CLUSTER);

to basically get the same behavior as mongosh $CLUSTER

Copy link
Contributor Author

@lerouxb lerouxb May 30, 2025

Choose a reason for hiding this comment

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

Do you have an idea of a better thing to check?

Copy link
Collaborator

Choose a reason for hiding this comment

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

You'd have to check what the methods on getAutocompletionContext() return (/whether they return), I'd say

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed the code from here. Will add it to mongodb-ts-autocomplete separately

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@lerouxb lerouxb merged commit c8941c1 into main Jun 3, 2025
120 of 126 checks passed
@lerouxb lerouxb deleted the lazy-load branch June 3, 2025 12:41
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.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.