Skip to content

Commit

Permalink
FIX #125 temporaryDocument throws when setting field to null
Browse files Browse the repository at this point in the history
  • Loading branch information
pubkey committed Jul 11, 2017
1 parent 969bc6d commit c2a5878
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/RxDocument.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ class RxDocument {
}

_defineGetterSetter(valueObj, objPath = '') {
if (valueObj === null) return;

let pathProperties = this.collection.schema.getSchemaByObjectPath(objPath);
if (pathProperties.properties) pathProperties = pathProperties.properties;

Expand Down
14 changes: 13 additions & 1 deletion test/unit/TemporaryDocument.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('TemporaryDocument.test.js', () => {
assert.equal(newDoc.firstName, 'foobar');
c.database.destroy();
});
it('should be possible to set the primary', async()=>{
it('should be possible to set the primary', async() => {
const c = await humansCollection.createPrimary(0);
const newDoc = c.newDocument();
newDoc.passportId = 'foobar';
Expand Down Expand Up @@ -120,4 +120,16 @@ describe('TemporaryDocument.test.js', () => {
c.database.destroy();
});
});
describe('ISSUES', () => {
describe('#215 setting field to null throws', () => {
it('reproduce', async() => {
const c = await humansCollection.create(0);
const newDoc = c.newDocument();
newDoc.age = null;
newDoc.age = 10;
assert.equal(newDoc.age, 10);
c.database.destroy();
});
});
});
});

0 comments on commit c2a5878

Please sign in to comment.