[GODRIVER-2323] updateone function issue Created: 26/Feb/22  Updated: 28/Oct/23  Resolved: 11/Apr/22

Status: Closed
Project: Go Driver
Component/s: None
Affects Version/s: 1.7.5, 1.8.1, 1.8.2, 1.8.3
Fix Version/s: 1.9.1

Type: Bug Priority: Major - P3
Reporter: Sachin Sanjay Assignee: Matt Dale
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Summary

when using the updateone function it results in 

response field ‘n’ is type int32, but received BSON type 64-bit integer

This error does not appear before version 1.7.5 of the driver 

 

Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).

Any version from 1.7.5 onwards

How to Reproduce

running any simple example of updateone leads to the issue 

the following code is taken from the mongo DB example in the documentation

opts := options.Update().SetUpsert(true) opts := options.Update().SetUpsert(true) filter := bson.D{{"_id", id}} update := bson.D{{"$set", bson.D{{"email", "newemail@example.com"}}}}
result, err := coll.UpdateOne(context.TODO(), filter, update, opts) if err != nil { log.Fatal(err) }

 



 Comments   
Comment by Matt Dale [ 11/Apr/22 ]

Hey sachinhydratech@gmail.com, I just merged a change to add support for int32/int64 to UpdateOne (and all numeric fields in all other CRUD operations). The fix will be included with the next patch release (v1.9.1), which is scheduled for May 3. I'm closing this ticket for now, please respond here if you have any further questions. Thanks!

Comment by Githook User [ 11/Apr/22 ]

Author:

{'name': 'Matt Dale', 'email': '9760375+matthewdale@users.noreply.github.com', 'username': 'matthewdale'}

Message: GODRIVER-2323 Support int64 for 'n' field in insert, update, and delete ops. (#905)
Branch: release/1.9
https://github.com/mongodb/mongo-go-driver/commit/7ff10a8611161d71303106eeacc869f5f6a4e9e3

Comment by Githook User [ 11/Apr/22 ]

Author:

{'name': 'Matt Dale', 'email': '9760375+matthewdale@users.noreply.github.com', 'username': 'matthewdale'}

Message: GODRIVER-2323 Support int64 for 'n' field in insert, update, and delete ops. (#905)
Branch: master
https://github.com/mongodb/mongo-go-driver/commit/5fe9dc5c4b63f496d2dcf791e8ca055a732fce97

Comment by Sachin Sanjay [ 08/Mar/22 ]

Hey Matt, As requested I did more research on the server-side and figured out it is hosted on Azure Cosmos DB which by default runs document DB I've failed to notice this since it was working with the prior version of golang MongoDB driver 1.7.5. I think ever since the driver updates the update function breaks.

I apologize for the misunderstanding, thanks for the help

Comment by Matt Dale [ 07/Mar/22 ]

Hey sachinhydratech@gmail.com thanks for filing a ticket! It's unusual that the server response field "n" would be a 64-bit integer, as drivers expect that field to always be a 32-bit integer.

I have a few questions to help get to the cause of the issue:

  • What MongoDB server version are you using?
  • Are you using Atlas, Ops Manager, or a self-managed MongoDB deployment?
  • What MongoDB server topology are you using? E.g. a single node, a replica set, a sharded cluster?
Generated at Thu Feb 08 08:38:19 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.