[CXX-797] Updating entire document without operators such as set fails at execution with Cannot do an empty bulk write Created: 05/Jan/16 Updated: 05/Jan/16 Resolved: 05/Jan/16 |
|
| Status: | Closed |
| Project: | C++ Driver |
| Component/s: | Implementation |
| Affects Version/s: | 0.2.0 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Amit Ambasta | Assignee: | Tess Avitabile (Inactive) |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Epic Link: | C++11 Driver MongoDB 3.2 | ||||||||
| Description |
|
As per mongodb documentation, updating entire document is possible as:
One need provide update operators such as $set only when updating sub-document. The same should be achieveable with the C++11 driver as:
However, executing the above code leads to
|
| Comments |
| Comment by Tess Avitabile (Inactive) [ 05/Jan/16 ] | ||||||||||
|
amit.ambasta@delhivery.com, replace_one should be used instead of update for replacing an entire document. This is done to prevent accidentally replacing an entire object. We are closing this ticket, but feel free to re-open if you have further comments or suggestions, and we appreciate your testing the new driver. | ||||||||||
| Comment by Amit Ambasta [ 05/Jan/16 ] | ||||||||||
|
I have been using replace_one or update operators as needed currently. I just wanted to point out the issue. Not sure if this is the intended behaviour but I am guessing this is due to the fact that all modifer operations internally use the bulk operator to execute appropriate changes. | ||||||||||
| Comment by Tess Avitabile (Inactive) [ 05/Jan/16 ] | ||||||||||
|
Hi amit.ambasta@delhivery.com. I will look into this issue. In the meantime, note that you can use replace_one instead of update_one to replace an entire document. | ||||||||||
| Comment by Amit Ambasta [ 05/Jan/16 ] | ||||||||||
|
Mongo command w/o upsert option
|