vertx-mongo-client icon indicating copy to clipboard operation
vertx-mongo-client copied to clipboard

Update fails to encode _id

Open johnoliver opened this issue 6 years ago • 0 comments

updateCollectionWithOptions uses encodeKeyWhenUseObjectId that assumes that the _id is at the top level of the JsonObject, if an update is of the form:

{ 
  $set:{
    _id='an-id', 
    foo:'bar'
  }
}

The _id is nested so it will fail to encode the _id and throw an exception.

It may seem odd to have _id in an update, but I have tested with the mongo command line client and it accepts _id in the update provided it does not change the value. If we dont encode it we would probably need to warn people that their code needs to filter out _id from any updates.

johnoliver avatar Apr 09 '18 15:04 johnoliver