surrealdb.net
surrealdb.net copied to clipboard
Problem with null values on schemafull tables
I have created a schemafull table with an optional field (option
Hello @armandoradan
You are correct. Default value for class objects are null
which is different than NONE
in the SurrealDB world. You can use the [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
or [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
attribute on your properties so that it will never be in the JSON payload, then being treated as NONE
.
I suppose the only missing part would be to force to NONE
on merge/patch method. I have plan to add custom attributes to handle the different use cases (also being agnostic to the serialization format). Custom attributes could have the form of:
-
[IgnoreIfNull]
-
[IgnoreIfDefault]
-
[TreatAsNoneIfNull]
-
[TreatAsNoneIfDefault]
Thank you @Odonno