[CSHARP-1338] Bulk Upsert result object's InsertedCount property value is always 0 Created: 26/Jun/15  Updated: 27/Jun/15  Resolved: 26/Jun/15

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: 1.10
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Mikhail Manukhin [X] Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Bulk Upsert result object's InsertedCount property value is always 0

It could a bug of mongodb iteslf.
I noticed it on mongo 2.6.1 version with 1.10.0.62 version of .NET driver.



 Comments   
Comment by Mikhail Manukhin [X] [ 27/Jun/15 ]

So that Upserts collection contains only "Inserts" for Upsert command. Quite tricky BTW.

Comment by Robert Stam [ 26/Jun/15 ]

Yes, it is possible.

If the Upserts collection is empty then an existing document was updated. If the Upserts collection is not empty, then a new document was upserted.

Comment by Mikhail Manukhin [X] [ 26/Jun/15 ]

Ok, thanks! So, it is not possible to understand whether the record was added or updated after sending it within upsert operation?

Comment by Robert Stam [ 26/Jun/15 ]

That is correct.

Upserts are not counted as Inserts in the BulkWriteResult returned by calling Execute on the BulkWriteOperation. Only Inserts are counted as Inserts.

You can tell how many upserts there were by checking the Count property of the Upserts collection of the BulkWriteResult. The Upserts collection also reports the actual _id values used by the Upserts.

Generated at Wed Feb 07 21:39:18 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.