Let's assume that I'm running the integration tests and the my_field array only has one document. In this case, I'm expecting the $ operator to become the index 0, but unfortunately this is not the case and the example above will actually insert a new document into the array at index 1.
I validated that this is a bug by manually replacing the operator with the expected index, and then the integration tests pass:
At first glance, this doesn't look like behavior specific to the Rust driver. Can you check with the driver for a different language and see if this behavior is present there as well?
Versions/Environment
mongodb
2.5.0 andbson
2.6.1Describe the bug
Using the
$
positional operator in anupdate_one
operation gets the index for the update wrong.To Reproduce
Example of the query that shows the error:
Let's assume that I'm running the integration tests and the
my_field
array only has one document. In this case, I'm expecting the$
operator to become the index0
, but unfortunately this is not the case and the example above will actually insert a new document into the array at index 1.I validated that this is a bug by manually replacing the operator with the expected index, and then the integration tests pass: