fix for setting properties to objects from other realms
This commit is contained in:
parent
cb889ea8f8
commit
81feca0ce9
|
@ -7,7 +7,7 @@ x.x.x Release notes (yyyy-MM-dd)
|
||||||
* Added `isValid()` method to `List` and `Results` to check for deleleted or invalidated objects
|
* Added `isValid()` method to `List` and `Results` to check for deleleted or invalidated objects
|
||||||
|
|
||||||
### Bugfixes
|
### Bugfixes
|
||||||
* None
|
* Fix for crash when setting object properties to objects from other Realms
|
||||||
|
|
||||||
0.13.2 Release notes (2016-5-26)
|
0.13.2 Release notes (2016-5-26)
|
||||||
=============================================================
|
=============================================================
|
||||||
|
|
|
@ -106,7 +106,10 @@ struct NativeAccessor {
|
||||||
static size_t to_object_index(ContextType ctx, SharedRealm realm, ValueType &value, const std::string &type, bool try_update) {
|
static size_t to_object_index(ContextType ctx, SharedRealm realm, ValueType &value, const std::string &type, bool try_update) {
|
||||||
ObjectType object = Value::validated_to_object(ctx, value);
|
ObjectType object = Value::validated_to_object(ctx, value);
|
||||||
if (Object::template is_instance<RealmObjectClass<T>>(ctx, object)) {
|
if (Object::template is_instance<RealmObjectClass<T>>(ctx, object)) {
|
||||||
return get_internal<T, RealmObjectClass<T>>(object)->row().get_index();
|
auto realm_object = get_internal<T, RealmObjectClass<T>>(object);
|
||||||
|
if (realm_object->realm() == realm) {
|
||||||
|
return realm_object->row().get_index();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto object_schema = realm->config().schema->find(type);
|
auto object_schema = realm->config().schema->find(type);
|
||||||
|
|
|
@ -328,6 +328,17 @@ module.exports = {
|
||||||
TestCase.assertEqual(obj.arrayCol[0].doubleCol, 3);
|
TestCase.assertEqual(obj.arrayCol[0].doubleCol, 3);
|
||||||
TestCase.assertEqual(obj.arrayCol[1].doubleCol, 1);
|
TestCase.assertEqual(obj.arrayCol[1].doubleCol, 1);
|
||||||
TestCase.assertEqual(obj.arrayCol[2].doubleCol, 2);
|
TestCase.assertEqual(obj.arrayCol[2].doubleCol, 2);
|
||||||
|
|
||||||
|
// set object from another realm
|
||||||
|
var another = new Realm({path: 'another.realm', schema: realm.schema});
|
||||||
|
var anotherObj;
|
||||||
|
another.write(function() {
|
||||||
|
anotherObj = another.create('TestObject', {doubleCol: 3});
|
||||||
|
});
|
||||||
|
realm.write(function() {
|
||||||
|
obj.objectCol = anotherObj;
|
||||||
|
});
|
||||||
|
TestCase.assertEqual(obj.objectCol.doubleCol, 3);
|
||||||
},
|
},
|
||||||
testEnumerablePropertyNames: function() {
|
testEnumerablePropertyNames: function() {
|
||||||
var realm = new Realm({schema: [schemas.BasicTypes]});
|
var realm = new Realm({schema: [schemas.BasicTypes]});
|
||||||
|
|
Loading…
Reference in New Issue