Skip to content

Commit

Permalink
Allow more nullable property types when supported
Browse files Browse the repository at this point in the history
  • Loading branch information
tgoyne committed Sep 9, 2015
1 parent 0eb0bd1 commit f79dec9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions object_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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) {
Expand Down Expand Up @@ -515,6 +521,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.";
Expand All @@ -525,6 +534,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) :
Expand Down

0 comments on commit f79dec9

Please sign in to comment.