Setting a field to null or undefined does not unset it. Is it possible with a PATCH request at all?
Null is a valid value and undefined
is not a valid json value (but the deserializer accepts it), so it is logically not possible to unset a value with PATCH.
Null is a valid value in Squidex? Can you explain in which situations? If I set a string field to null in a PUT request it will save that field with no value, i.e. unset it. Why is the same not happening when I send a null during a PATCH request? If I understand this correctly, a null should unset the field in the PATCH as it does it in the PUT. This feels like a bug to me.
Lets say you have a string that represents a campaign ID or so.
So you have the following field
{
"campaignId": {
"en": "super-product"
"de": null
}
}
if you have 3 languages (en, de, it) you can use the fallback system for localization.
If you query “en” you get “super-product”
if you query “de” you get null
(no campaign)
If you query “it” you get “super-product” because it has no value and falls back to “en”
What do you mean exactly?
I see what you mean. at the moment Squidex makes ca cleanup of the data and removes all null values before it processes it. Not sure why I did that, I have to remove this code probably.
I am not sure about the implications so far.
Thanks @Sebastian, I appreciate your quick response. Yes, this is what I mean, we are currently unable to nullify any values through the API.
As far as I can tell the only other option is to set this value to an empty string, but it is not the same thing (in fact it’s totally different, but could be used as a temporary workaround). Are you planning on fixing/changing this behaviour any time soon?
Yes, I will probably change this soon, I am just a little bit scared
Hello Sebastian. Have you been able to overcome your fears and make the change?
Let me know how you’re getting on with it, thanks!
Yes, will be deployed soon.