Allow more nullable property types when supported

This commit is contained in:
Thomas Goyne 2015-09-03 14:54:41 -07:00 committed by Ari Lazier
parent 663492e9da
commit 873d24f3f0
1 changed files with 10 additions and 0 deletions

View File

@ -198,6 +198,11 @@ std::vector<ObjectSchemaValidationException> ObjectStore::verify_object_schema(O
}
// check nullablity
#if REALM_NULL_STRINGS == 1
if (current_prop.type == PropertyTypeArray && current_prop.is_nullable) {
exceptions.emplace_back(InvalidNullabilityException(table_schema.name, current_prop));
}
#else
if (current_prop.type == PropertyTypeObject) {
if (!current_prop.is_nullable) {
exceptions.emplace_back(InvalidNullabilityException(table_schema.name, current_prop));
@ -208,6 +213,7 @@ std::vector<ObjectSchemaValidationException> ObjectStore::verify_object_schema(O
exceptions.emplace_back(InvalidNullabilityException(table_schema.name, current_prop));
}
}
#endif
// check primary keys
if (current_prop.is_primary) {
@ -516,6 +522,9 @@ MissingPropertyException::MissingPropertyException(std::string object_type, Prop
InvalidNullabilityException::InvalidNullabilityException(std::string object_type, Property const& property) :
ObjectSchemaPropertyException(object_type, property)
{
#if REALM_NULL_STRINGS == 1
m_what = "'Array' property '" + property.name + "' cannot be nullable";
#else
if (property.type == PropertyTypeObject) {
if (!property.is_nullable) {
m_what = "'Object' property '" + property.name + "' must be nullable.";
@ -526,6 +535,7 @@ InvalidNullabilityException::InvalidNullabilityException(std::string object_type
m_what = "Only 'Object' property types are nullable";
}
}
#endif
}
MissingObjectTypeException::MissingObjectTypeException(std::string object_type, Property const& property) :