Open sFreezer opened 4 years ago
I'm afraid this is not going to happen unless we have explicit upsert
support where we could give users control over setting null
values (or not). Also changing the current behaviour would be a quite huge BC break given we introduced the change in 1.2 series.
As you can read in your docs
the nullable flag should do something else.
Option 1: this is a bug or Option 2: the docs are wrong
The nullable flag description is correct, that's what is happening during insert and update, it is just upsert that works differently. If we don't have a section about upserting documents and its quirks, we shall write one.
Bug Report
Summary
After this -> change
you can not overwrite any value on a nullable field to null with upsert. because it is just set on $setOnInsert and not on $set. I think: this was done to not overwrite a value by accident (by not calling the setter)
but we need to overwrite a value by setting it to null on purpose
Current behavior
$someNullabeInt will be 2 after running this code but it should be null
How to reproduce
by running the test from #Current behavior
Expected behavior
we need to be able to overwrite a value with null on purpose by calling the setter on null