From 0a4e0665ae89dc0aeca9055c9486d5019dcf6c55 Mon Sep 17 00:00:00 2001 From: Ari Lazier Date: Mon, 13 Jun 2016 14:46:26 -0700 Subject: [PATCH] fixes for typos and added upsert test --- src/object-store/src/binding_context.hpp | 2 +- src/object-store/src/object_accessor.hpp | 2 +- tests/js/realm-tests.js | 15 ++++++++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/object-store/src/binding_context.hpp b/src/object-store/src/binding_context.hpp index d57ce541..8290144b 100644 --- a/src/object-store/src/binding_context.hpp +++ b/src/object-store/src/binding_context.hpp @@ -80,7 +80,7 @@ public: struct ObserverState; - // Override this function if you want to recieve detailed information about + // Override this function if you want to receive detailed information about // external changes to a specific set of objects. // This is called before each operation which may advance the read // transaction to include diff --git a/src/object-store/src/object_accessor.hpp b/src/object-store/src/object_accessor.hpp index f57f42e7..6becf0bd 100644 --- a/src/object-store/src/object_accessor.hpp +++ b/src/object-store/src/object_accessor.hpp @@ -322,7 +322,7 @@ namespace realm { if (!try_update && row_index != realm::not_found) { throw DuplicatePrimaryKeyValueException(object_schema.name, *primary_prop, - "Attempting to create an object of type '" + object_schema.name + "' with an exising primary key value."); + "Attempting to create an object of type '" + object_schema.name + "' with an existing primary key value."); } } diff --git a/tests/js/realm-tests.js b/tests/js/realm-tests.js index ec426327..6a9ba6b8 100644 --- a/tests/js/realm-tests.js +++ b/tests/js/realm-tests.js @@ -273,7 +273,7 @@ module.exports = { }, testRealmCreateUpsert: function() { - var realm = new Realm({schema: [schemas.IntPrimary, schemas.AllTypes, schemas.TestObject]}); + var realm = new Realm({schema: [schemas.IntPrimary, schemas.StringPrimary, schemas.AllTypes, schemas.TestObject]}); realm.write(function() { var values = { primaryCol: '0', @@ -360,6 +360,19 @@ module.exports = { realm.create('AllTypesObject', {primaryCol: '1', objectCol: null}, true); TestCase.assertEqual(obj0.objectCol, null); TestCase.assertEqual(obj1.objectCol, null); + + // test with string primaries + var obj =realm.create('StringPrimaryObject', { + primaryCol: '0', + valueCol: 0 + }); + TestCase.assertEqual(obj.valueCol, 0); + + realm.create('StringPrimaryObject', { + primaryCol: '0', + valueCol: 1 + }, true); + TestCase.assertEqual(obj.valueCol, 1); }); },