Hi there,
I’m trying to build an app using Realm Sync feature but I face an issue that i don’t understand.
In Realm schema, I define an class with some fields marked as required.
On the app side, an object is instantiated.
What i noticed :
if a mandatory int field is set to 0, a string field is set to “” or a boolean is set to false, at creation time, the matching field are not created in the atlas Document.
no big trouble until then, BUT , if you stop the Sync ( change in the schema or in sync config ), then it is not possible to turn it on again cleanly as object won’t get re synchronized.
Log shows message complaining about missing required field ( which is true as they’re missing in atlas documents) .
here is my class schema definition:
{
"title": "Log",
"bsonType": "object",
"properties": {
"_id": {
"bsonType": "objectId"
},
"__partition": {
"bsonType": "string"
},
"type": {
"bsonType": "int"
},
"result": {
"bsonType": "bool"
},
"message": {
"bsonType": "string"
},
"authorId": {
"bsonType": "string"
},
"createdOn": {
"bsonType": "date"
}
},
"required": [
"_id",
"result",
"type",
"message",
"authorId",
"createdOn"
]
}
an instance of Log object is created with “type” field set to 0 and message set to an empty string.
Here is what i get in the atlas collection
{“_id”:{“$oid”:“604b7c401fcf488cfeec9f51”},“__partition”:“xxx”,“authorId”:“id”,“createdOn”:{“$date”:“2021-03-12T14:35:44.105Z”},“result”:true}
A small precision: if these fields are set to a different value then set back to the wanted one (0, false or “” ), then the field remain present in the atlas document.
This look like a bug.
Am I missing something in my schema declaration or in Atlas configuration?
Thanks in advance.