microsoft / vscode-cosmosdb

Azure Databases extension for VS Code
https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-cosmosdb
MIT License
155 stars 68 forks source link

The last command 'db.lotsofdata.find().pretty();' is not executed after clicking "Execute All" #2233

Closed v-xinda closed 6 months ago

v-xinda commented 8 months ago

OS: All Build Version: 20240112.17 Regression: Not a regression

Repro Steps:

  1. Create a MongoDB account -> Create a database -> Connect the database.
  2. Create a scrapbook and type the following.
        db.lotsofdata.drop();
        db.lotsofdata.insertMany([{"a": "xxxxxxxxxxxxxxxxxxx"},
        {"a": "xxxxxxxxxxxxxxxxxxx"},
        {"b": "xxxxxxxxxxxxxxxxxxx"},
        {"c": "xxxxxxxxxxxxxxxxxxx"},
        {"d": "xxxxxxxxxxxxxxxxxxx"},
        {"e": "xxxxxxxxxxxxxxxxxxx"},
        {"f": "xxxxxxxxxxxxxxxxxxx"},
        {"g": "xxxxxxxxxxxxxxxxxxx"},
        {"h": "xxxxxxxxxxxxxxxxxxx"},
        {"i": "xxxxxxxxxxxxxxxxxxx"},
        {"j": "xxxxxxxxxxxxxxxxxxx"},
        {"k": "xxxxxxxxxxxxxxxxxxx"},
        {"l": "xxxxxxxxxxxxxxxxxxx"},
        {"m": "xxxxxxxxxxxxxxxxxxx"},
        {"n": "xxxxxxxxxxxxxxxxxxx"},
        {"o": "xxxxxxxxxxxxxxxxxxx"},
        {"p": "xxxxxxxxxxxxxxxxxxx"},
        {"q": "xxxxxxxxxxxxxxxxxxx"},
        {"r": "xxxxxxxxxxxxxxxxxxx"},
        {"s": "xxxxxxxxxxxxxxxxxxx"},
        {"t": "xxxxxxxxxxxxxxxxxxx"},
        {"u": "xxxxxxxxxxxxxxxxxxx"},
        {"v": "xxxxxxxxxxxxxxxxxxx"},
        {"w": "xxxxxxxxxxxxxxxxxxx"},
        {"x": "xxxxxxxxxxxxxxxxxxx"},
        {"y": "xxxxxxxxxxxxxxxxxxx"},
        {"z": "xxxxxxxxxxxxxxxxxxx"}]);
        db.lotsofdata.find().pretty();
  3. Click "Execute All".
  4. Check whether all commands are executed successfully.

Expect: All commands are executed successfully. The result as below: image

Actual: The last command db.lotsofdata.find().pretty(); is not executed. The result as below: image

JasonYeMSFT commented 6 months ago

@v-xinda Did you see any error in the notification or in the output channel of "Azure Databases"? The last command requires the user to install a local Mongosh (Mongo Shell) and configure its path in the setting mongo.shell.path. Have you configured that?

This doc explains how to install the MongoDB, which includes Mongosh for each platform. https://www.mongodb.com/docs/manual/installation/

v-xinda commented 6 months ago

@JasonYeMSFT Verified this issue on the current release version. There is no error in the notification or in the output channel of "Azure Databases".

2:13:07 AM: Executing all commands in scrapbook...
Starting executable: "c:\Program Files\MongoDB\Server\5.0\bin\mongo.exe" --quiet mongodb://anicole-m1:redacted@anicole-m1.mongo.cosmos.azure.com:10255/test45?ssl=true&replicaSet=globaldb&retrywrites=false&maxIdleTimeMS=120000&appName=@anicole-m1@

> DBQuery.shellBatchSize = 50
50

> use test45
switched to db test45

> db.lotsofdata.find().pretty();
{ "_id" : ObjectId("65d5ccb633d63b1508ba4763"), "a" : "xxxxxxxxxxxxxxxxxxx" }
{ "_id" : ObjectId("65d5ccb633d63b1508ba4764"), "a" : "xxxxxxxxxxxxxxxxxxx" }

{ "_id" : ObjectId("65d5ccb633d63b1508ba4765"), "b" : "xxxxxxxxxxxxxxxxxxx" }
{ "_id" : ObjectId("65d5ccb633d63b1508ba4766"), "c" : "xxxxxxxxxxxxxxxxxxx" }
{ "_id" : ObjectId("65d5ccb633d63b1508ba4767"), "d" : "xxxxxxxxxxxxxxxxxxx" }
{ "_id" : ObjectId("65d5ccb633d63b1508ba4768"), "e" : "xxxxxxxxxxxxxxxxxxx" }
{ "_id" : ObjectId("65d5ccb633d63b1508ba4769"), "f" : "xxxxxxxxxxxxxxxxxxx" }
{ "_id" : ObjectId("65d5ccb633d63b1508ba476a"), "g" : "xxxxxxxxxxxxxxxxxxx" }
{ "_id" : ObjectId("65d5ccb633d63b1508ba476b"), "h" : "xxxxxxxxxxxxxxxxxxx" }
{ "_id" : ObjectId("65d5ccb633d63b1508ba476c"), "i" : "xxxxxxxxxxxxxxxxxxx" }
{ "_id" : ObjectId("65d5ccb633d63b1508ba476d"), "j" : "xxxxxxxxxxxxxxxxxxx" }
{ "_id" : ObjectId("65d5ccb633d63b1508ba476e"), "k" : "xxxxxxxxxxxxxxxxxxx" }
{ "_id" : ObjectId("65d5ccb633d63b1508ba476f"), "l" : "xxxxxxxxxxxxxxxxxxx" }

{ "_id" : ObjectId("65d5ccb633d63b1508ba4770"), "m" : "xxxxxxxxxxxxxxxxxxx" }
{ "_id" : ObjectId("65d5ccb633d63b1508ba4771"), "n" : "xxxxxxxxxxxxxxxxxxx" }
{ "_id" : ObjectId("65d5ccb633d63b1508ba4772"), "o" : "xxxxxxxxxxxxxxxxxxx" }

{ "_id" : ObjectId("65d5ccb633d63b1508ba4773"), "p" : "xxxxxxxxxxxxxxxxxxx" }
{ "_id" : ObjectId("65d5ccb633d63b1508ba4774"), "q" : "xxxxxxxxxxxxxxxxxxx" }
{ "_id" : ObjectId("65d5ccb633d63b1508ba4775"), "r" : "xxxxxxxxxxxxxxxxxxx" }
{ "_id" : ObjectId("65d5ccb633d63b1508ba4776"), "s" : "xxxxxxxxxxxxxxxxxxx" }

{ "_id" : ObjectId("65d5ccb633d63b1508ba4777"), "t" : "xxxxxxxxxxxxxxxxxxx" }
{ "_id" : ObjectId("65d5ccb633d63b1508ba4778"), "u" : "xxxxxxxxxxxxxxxxxxx" }
{ "_id" : ObjectId("65d5ccb633d63b1508ba4779"), "v" : "xxxxxxxxxxxxxxxxxxx" }
{ "_id" : ObjectId("65d5ccb633d63b1508ba477a"), "w" : "xxxxxxxxxxxxxxxxxxx" }
{ "_id" : ObjectId("65d5ccb633d63b1508ba477b"), "x" : "xxxxxxxxxxxxxxxxxxx" }
{ "_id" : ObjectId("65d5ccb633d63b1508ba477c"), "y" : "xxxxxxxxxxxxxxxxxxx" }
{ "_id" : ObjectId("65d5ccb633d63b1508ba477d"), "z" : "xxxxxxxxxxxxxxxxxxx" }

I installed MongoDB and configured its path in the setting mongo.shell.path. The details as below: image image

JasonYeMSFT commented 6 months ago

@v-xianda Ya, this is an acceptable behavior. The extension doesn't have built-in support for running the "find" command so it will delegate it to the MongoDB shell to execute it and present the result. I noticed that there is a discrepancy since when I tested it, it would open a new document with the results (list of objects). I need to look at more details of this feature area to determine what's going on.

JasonYeMSFT commented 6 months ago

@v-xianda Last time when you were able to see the output for the last command in the output, did you see the same output show up in a read-only output document?

v-xinda commented 6 months ago

@JasonYeMSFT The output log is same but the result is incorrect. The correct result should be like below: image

JasonYeMSFT commented 6 months ago

According to this documentation, pretty() will have only affect the output format in legacy mongo shell https://www.mongodb.com/docs/manual/reference/method/cursor.pretty/#behavior. The output format of the mongo shell is out of our control. It's good enough for us to forward the output from the mongo shell and present it in the document.