mongo-java-driver icon indicating copy to clipboard operation
mongo-java-driver copied to clipboard

Update Updates.set to allow Bson value argument

Open tyilo opened this issue 1 year ago • 1 comments

tyilo avatar Sep 06 '24 09:09 tyilo

Hi @tyilo thanks for the PR.

I have added a Jira ticket JAVA-5620 to track this improvement request. It will be triaged in due course.

Cheers,

Ross

rozza avatar Sep 23 '24 10:09 rozza

@tyilo Could you please give us more context on why this is important? We believe our API currently fully supports the $set syntax. Could you give us more examples and why this new method makes things better than the existing API?

atandon2024 avatar Sep 08 '25 16:09 atandon2024

This matches the current setOnInsert function which is also overloaded.

tyilo avatar Sep 09 '25 11:09 tyilo

I'm inclined to agree that for setting multiple values a Bson object may be helpful.

Could you add a test case to: UpdatesSpecification - something on the lines of:

toBson(set(parse('{ a : 1, b: "two"}'))) == parse('{$set : {a: 1, b: "two"} }')

rozza avatar Sep 23 '25 13:09 rozza

Many thanks @tyilo for the PR - this has been merged and will be released in the next minor release (5.7.0).

rozza avatar Sep 24 '25 10:09 rozza