[GODRIVER-1189] When I tried Count function against Azure CosmosDB with MongoDB Api, an error is returned read "Invalid response from server, value field is not a number". The same code returned the number of items when ran against a MongoDB database. Created: 04/Jul/19  Updated: 12/Jul/19  Resolved: 12/Jul/19

Status: Closed
Project: Go Driver
Component/s: None
Affects Version/s: 1.0.3
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Serdar Kalaycı Assignee: Emmanuel Eppinger (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Azure CosmosDB



 Comments   
Comment by Emmanuel Eppinger (Inactive) [ 12/Jul/19 ]

Hi Serdar,

 

So it looks like MongoDB returns an int32 in the n field and CosmosDB seems to return an Int64 and for some reason, the .Net driver is able to deal with that. We don't test any of our drivers with Cosmos so it is probably a coincidence that the .Net driver is able to support that. 

 

EDIT: It seems like the Go driver accepts int32, int64, and doubles for the count response. If you'd like to dig into this deeper, you can use https://docs.mongodb.com/manual/reference/program/bsondump/ to compare the bson results returned from mongo vs cosmos. 

 

Thanks

Emmanuel

Comment by Serdar Kalaycı [ 12/Jul/19 ]

Hi Emmanuel,

I'm aware that CosmosDB is not fully compatible to MongoDB. But the .Net driver I used in my inquiries are also developed buy MongoDB and it handles what CosmosDB returns without a complaint. That's why I wanted to bring it to your attention.

Comment by Emmanuel Eppinger (Inactive) [ 09/Jul/19 ]

Hi Serdar,

Thank you for bringing this to our attention. However, we officially develop, test, and support the driver when running with MongoDB.

CosmosDB implements an emulation of the MongoDB API, therefore there is only limited compatibility for queries that run from MongoDB drivers against CosmosDB. The best way to run MongoDB in Azure is via the MongoDB Atlas service. You can see a comparison of functionality here: https://www.mongodb.com/cloud/atlas/compare

Cheers,

Emmanuel

Comment by Serdar Kalaycı [ 04/Jul/19 ]

C# drivers works as expected with both databases. When I try to apply the same query via Robo3T, I saw that CosmosDB returns NumberLong(532) instead of just 532. 

Generated at Thu Feb 08 08:35:52 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.