Merge pull request #416 from realm/al-ignored

Allow setting of non-persisted properties
This commit is contained in:
Ari Lazier 2016-05-03 13:47:44 -07:00
commit 513c0fee77
3 changed files with 20 additions and 1 deletions

View File

@ -18,6 +18,7 @@
* Accessing an invalidated Results snapshot throws a JS exception rather than crashing * Accessing an invalidated Results snapshot throws a JS exception rather than crashing
* Fix for error message when specifying properties with invalid object types * Fix for error message when specifying properties with invalid object types
* Fix memory leak when reloading an app in debug mode * Fix memory leak when reloading an app in debug mode
* Setting non-persisted properties now works as expected
0.11.1 Release notes (2016-3-29) 0.11.1 Release notes (2016-3-29)
============================================================= =============================================================

View File

@ -110,7 +110,12 @@ void RealmObject<T>::get_property(ContextType ctx, ObjectType object, const Stri
template<typename T> template<typename T>
bool RealmObject<T>::set_property(ContextType ctx, ObjectType object, const String &property, ValueType value) { bool RealmObject<T>::set_property(ContextType ctx, ObjectType object, const String &property, ValueType value) {
auto realm_object = get_internal<T, RealmObjectClass<T>>(object); auto realm_object = get_internal<T, RealmObjectClass<T>>(object);
try {
realm_object->set_property_value(ctx, property, value, true); realm_object->set_property_value(ctx, property, value, true);
}
catch (InvalidPropertyException &ex) {
return false;
}
return true; return true;
} }

View File

@ -456,4 +456,17 @@ module.exports = BaseTest.extend({
obj.doubleCol; obj.doubleCol;
}); });
}, },
testIgnoredProperties: function() {
var realm = new Realm({schema: [schemas.TestObject]});
var obj;
realm.write(function() {
obj = realm.create('TestObject', {doubleCol: 1, ignored: true});
});
TestCase.assertEqual(obj.doubleCol, 1);
TestCase.assertEqual(obj.ignored, undefined);
obj.ignored = true;
TestCase.assertEqual(obj.ignored, true);
}
}); });