Merge pull request #488 from realm/al-typos
fixes for typos and added upsert test
This commit is contained in:
commit
c7e156a7b8
|
@ -80,7 +80,7 @@ public:
|
||||||
|
|
||||||
struct ObserverState;
|
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.
|
// external changes to a specific set of objects.
|
||||||
// This is called before each operation which may advance the read
|
// This is called before each operation which may advance the read
|
||||||
// transaction to include
|
// transaction to include
|
||||||
|
|
|
@ -322,7 +322,7 @@ namespace realm {
|
||||||
|
|
||||||
if (!try_update && row_index != realm::not_found) {
|
if (!try_update && row_index != realm::not_found) {
|
||||||
throw DuplicatePrimaryKeyValueException(object_schema.name, *primary_prop,
|
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.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -273,7 +273,7 @@ module.exports = {
|
||||||
},
|
},
|
||||||
|
|
||||||
testRealmCreateUpsert: function() {
|
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() {
|
realm.write(function() {
|
||||||
var values = {
|
var values = {
|
||||||
primaryCol: '0',
|
primaryCol: '0',
|
||||||
|
@ -360,6 +360,19 @@ module.exports = {
|
||||||
realm.create('AllTypesObject', {primaryCol: '1', objectCol: null}, true);
|
realm.create('AllTypesObject', {primaryCol: '1', objectCol: null}, true);
|
||||||
TestCase.assertEqual(obj0.objectCol, null);
|
TestCase.assertEqual(obj0.objectCol, null);
|
||||||
TestCase.assertEqual(obj1.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);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue