From d26924e2f9436421a1039e6e27f66489d3a011a1 Mon Sep 17 00:00:00 2001 From: Ari Lazier Date: Tue, 3 May 2016 13:05:48 -0700 Subject: [PATCH 1/2] allow setting of non-persisted properties --- src/js_realm_object.hpp | 7 ++++++- tests/js/object-tests.js | 13 +++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/js_realm_object.hpp b/src/js_realm_object.hpp index 961f42f4..a4839741 100644 --- a/src/js_realm_object.hpp +++ b/src/js_realm_object.hpp @@ -110,7 +110,12 @@ void RealmObject::get_property(ContextType ctx, ObjectType object, const Stri template bool RealmObject::set_property(ContextType ctx, ObjectType object, const String &property, ValueType value) { auto realm_object = get_internal>(object); - realm_object->set_property_value(ctx, property, value, true); + try { + realm_object->set_property_value(ctx, property, value, true); + } + catch (InvalidPropertyException &ex) { + return false; + } return true; } diff --git a/tests/js/object-tests.js b/tests/js/object-tests.js index db41c5dd..3abad10b 100644 --- a/tests/js/object-tests.js +++ b/tests/js/object-tests.js @@ -456,4 +456,17 @@ module.exports = BaseTest.extend({ 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); + } }); From df08fad4ea5a8033ae6fd944bd6e9edd2b58fe05 Mon Sep 17 00:00:00 2001 From: Ari Lazier Date: Tue, 3 May 2016 13:06:41 -0700 Subject: [PATCH 2/2] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 14e56271..7746e106 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ x.x.x Release notes (yyyy-MM-dd) * Accessing an invalidated Results snapshot throws a JS exception rather than crashing * Fix for error message when specifying properties with invalid object types * 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) =============================================================