Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"use" command behavior is finicky #355

Open
scoaste-st opened this issue Oct 19, 2021 · 1 comment
Open

"use" command behavior is finicky #355

scoaste-st opened this issue Oct 19, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@scoaste-st
Copy link

Bug Report

Current Behavior

Specifying the use command followed by a space, the database name, and a semicolon, does not properly select the database. For example:

use dbname;

will produce switched to db dbname; in the Playground Result tab, but a subsequent find db.colname.find({}); on a collection colname containing documents will produce no results.

However, if instead the command is issued as use('dbname'); the subsequent find command does return results.

Expected Behavior/Code

I would expect the use dbname;, followed by a valid find, to return documents in the specified collection. This syntax appears valid according to both mongo and mongosh shell documentation:

https://docs.mongodb.com/manual/reference/mongo-shell/

https://docs.mongodb.com/mongodb-shell/run-commands/

Environment

  • MongoDB for VS Code v0.6.12
  • OS: macOS Big Sur 11.6
@addaleax
Copy link
Contributor

Hi @scoaste-st!

We are aware of this problem and have a ticket to track work on our side: https://jira.mongodb.org/browse/MONGOSH-962

The main issue here is that use dbname; is not valid JavaScript, and we are not in a position where we would want to extend a custom JS parser to handle this specific case. We most likely will make the shell (and thus also vscode) reject input of this form and point the user towards the function-call-style equivalent in the error message.

@alenakhineika alenakhineika added the enhancement New feature or request label Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants