[SERVER-46484] Mongo shell doesn't allow updateOne operation with a pipeline Created: 26/Feb/20  Updated: 27/Oct/23  Resolved: 03/Mar/20

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Georgy Savva Assignee: Dmitry Agranat
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Robo 3T 1.3 on mac


Attachments: PNG File Screenshot 2020-02-26 at 13.21.37.png    
Backwards Compatibility: Fully Compatible
Participants:

 Description   

Hi. I am trying to execute quires from the documentation on my local Mongodb replica set with database version 4.2
https://docs.mongodb.com/manual/reference/method/db.collection.updateOne/#example-2

db.students3.updateOne(
   { _id: 3 },
   [
     { $set: { average: { $trunc: [  { $avg: "$tests" }, 0 ] }, lastUpdate: "$$NOW" } },
     { $set: { grade: { $switch: {
                           branches: [
                               { case: { $gte: [ "$average", 90 ] }, then: "A" },
                               { case: { $gte: [ "$average", 80 ] }, then: "B" },
                               { case: { $gte: [ "$average", 70 ] }, then: "C" },
                               { case: { $gte: [ "$average", 60 ] }, then: "D" }
                           ],
                           default: "F"
     } } } }
   ]
)

I get that error (You can see on the screenshoot):

Failed to execute script. Error: the update operation document must contain atomic operators Details: DBCollection.prototype.updateOne@src/mongo/shell/crud_api.js:542:1 @(shell):1:1

But when I execute this query in the mongo CLI or in the console on the documentation site - everything is fine. 



 Comments   
Comment by Dmitry Agranat [ 03/Mar/20 ]

georgy.savva@gmail.com since this works as expected with mongo shell 4.2, I will go ahead and close this ticket. For issues related to Robo 3T, please contact Robo support.

Comment by Georgy Savva [ 02/Mar/20 ]

Sorry for misleading you, I forgot to mention that this happening only in Robo 3T GUI.
So yes. It works as expected in mongo shell 4.2. Error persists only in Robo 3T.

Comment by Dmitry Agranat [ 01/Mar/20 ]

Hi georgy.savva@gmail.com, could you please clarify if this works as expected when you use mongo shell 4.2?

Generated at Thu Feb 08 05:11:38 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.