Can't Set Value to Null using Patch Operation
See original GitHub issueWe are continuously addressing and improving the SDK, if possible, make sure the problem persist in the latest SDK version.
Describe the bug
When using PatchOperation.Replace
, I am unable to set value to null. I have tried both null
and new JProperty(propName, null).Value
. The latter was attempted due to recommendation in #2931.
To Reproduce
This is the code used to create PatchOperation
: PatchOperation.Replace($"/{cosmosPropName}", propValue ?? createNullValue(cosmosPropName))
.
propValue
is type object?
. createNullValue()
creates the JProperty
mentioned in the description.
Expected behavior I would expect the property to be set to null value. Below example assumes description property is being set to null:
{
"id": "adfda-asdgasd-adsfasdf",
"partition_key": "aigeqwg-iuiou-qryqer",
"description": null
}
Actual behavior Description property is unchanged.
Environment summary SDK Version: 3.32.0 OS Version: Windows 10
Additional context Nothing additional to add.
Issue Analytics
- State:
- Created 3 months ago
- Comments:6 (2 by maintainers)
Top GitHub Comments
@aavasthy Found an issue in my logic. Updating versions does resolve it. Thank you!
Hi @aavasthy. Thank you for spending the time to reproduce. Do you think my problem is version, or lack of generic type? With my current implementation, I would not be able to supply type as I’m using reflection to get the value, which returns
object?
type.Edit: I suppose I can do something like this. I’ll check tomorrow if this resolves it (in addition to updating to latest version).