-
Type: Improvement
-
Resolution: Fixed
-
Priority: Trivial - P5
-
None
-
Affects Version/s: None
-
Component/s: ObjectStore
-
3 - M (<= 1 month)
-
4191
-
Not Needed
Errors thrown when opening a Realm (using Realm JS) with an invalid schema contains types and terminology which is not used anywhere in the RealmJS documentation.
For example, when accidentally defining a schema with a list with optional elements of some object type:
const Realm = require("realm"); new Realm({ schema: [{ name: "SomeClass", properties: { someList: { type: "list", objectType: "SomeClass", optional: true }, }, }], });
The following error [is thrown](
https://github.com/realm/realm-object-store/blob/master/src/object_schema.cpp#L167):
Error: Schema validation failed due to the following errors: - Property 'SomeClass.someList' of type 'array' cannot be nullable.
It uses words like "array" and "nullable", which is not a part of the Realm JS terminology. This is potentially very confusing for a newcomer trying to write a schemas and getting errors in the process.
I created this issue on the realm-object-store repository because I believe it should support some sort of mapping of these terms on a per-SDK level. An alternative solution would be to check for these conditions in Realm JS, before parsing a potentially invalid schema to object store, but that duplicates logic across multiple code-bases and that also didn't seem ideal.