mirror of
https://github.com/status-im/realm-js.git
synced 2025-01-11 23:04:29 +00:00
don't require optional or link properties when creating objects
This commit is contained in:
parent
c32dff40a2
commit
805fdc63a7
@ -208,10 +208,12 @@ namespace realm {
|
||||
case PropertyTypeArray: {
|
||||
realm::LinkViewRef link_view = m_row.get_linklist(column);
|
||||
link_view->clear();
|
||||
size_t count = Accessor::list_size(ctx, value);
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
ValueType element = Accessor::list_value_at_index(ctx, value, i);
|
||||
link_view->add(Accessor::to_object_index(ctx, m_realm, element, property.object_type, try_update));
|
||||
if (!Accessor::is_null(ctx, value)) {
|
||||
size_t count = Accessor::list_size(ctx, value);
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
ValueType element = Accessor::list_value_at_index(ctx, value, i);
|
||||
link_view->add(Accessor::to_object_index(ctx, m_realm, element, property.object_type, try_update));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -310,6 +312,9 @@ namespace realm {
|
||||
if (Accessor::has_default_value_for_property(ctx, realm.get(), object_schema, prop.name)) {
|
||||
object.set_property_value_impl(ctx, prop, Accessor::default_value_for_property(ctx, realm.get(), object_schema, prop.name), try_update);
|
||||
}
|
||||
else if (prop.is_nullable || prop.type == PropertyTypeArray) {
|
||||
object.set_property_value_impl(ctx, prop, Accessor::null_value(ctx), try_update);
|
||||
}
|
||||
else {
|
||||
throw MissingPropertyValueException(object_schema.name, prop.name,
|
||||
"Missing property value for property " + prop.name);
|
||||
|
Loading…
x
Reference in New Issue
Block a user