Fix null pointer includes (#2657)

* Adds failing test for #2189

* Improves support for null values in includes

* nit
This commit is contained in:
Florent Vilmart
2016-09-09 14:41:21 -04:00
committed by GitHub
parent fc576cb415
commit e8aa1ad312
2 changed files with 38 additions and 3 deletions

View File

@@ -235,4 +235,36 @@ describe('rest query', () => {
done();
});
});
it('makes sure null pointers are handed correctly #2189', done => {
let object = new Parse.Object('AnObject');
let anotherObject = new Parse.Object('AnotherObject');
anotherObject.save().then(() => {
object.set('values', [null, null, anotherObject]);
return object.save();
}).then(() => {
let query = new Parse.Query('AnObject');
query.include('values');
return query.first();
}).then((result) => {
let values = result.get('values');
expect(values.length).toBe(3);
let anotherObjectFound = false;
let nullCounts = 0;
for(let value of values) {
if (value === null) {
nullCounts++;
} else if (value instanceof Parse.Object) {
anotherObjectFound = true;
}
}
expect(nullCounts).toBe(2);
expect(anotherObjectFound).toBeTruthy();
done();
}, (err) => {
console.error(err);
fail(err);
done();
});
});
});