Allow queries with String array for pointers containedIn (#4188)

* Adds basic failing test

* Adds ability to use [objectId] for $in/$nin pointers

* makes sure to use a set field

* Makes sure field is defined
This commit is contained in:
Florent Vilmart
2017-10-03 13:50:39 -04:00
committed by GitHub
parent 2a168936fc
commit 7fac070435
2 changed files with 59 additions and 7 deletions

View File

@@ -2834,6 +2834,53 @@ describe('Parse.Query testing', () => {
});
});
it('containedIn with pointers should work with string array', done => {
const obj = new Parse.Object('MyClass');
const child = new Parse.Object('Child');
child.save().then(() => {
obj.set('child', child);
return obj.save();
}).then(() => {
const objs = [];
for(let i = 0; i < 10; i++) {
objs.push(new Parse.Object('MyClass'));
}
return Parse.Object.saveAll(objs);
}).then(() => {
const query = new Parse.Query('MyClass');
query.containedIn('child', [child.id]);
return query.find();
}).then((results) => {
expect(results.length).toBe(1);
}).then(done).catch(done.fail);
});
it('containedIn with pointers should work with string array, with many objects', done => {
const objs = [];
const children = [];
for(let i = 0; i < 10; i++) {
const obj = new Parse.Object('MyClass');
const child = new Parse.Object('Child');
objs.push(obj);
children.push(child);
}
Parse.Object.saveAll(children).then(() => {
return Parse.Object.saveAll(objs.map((obj, i) => {
obj.set('child', children[i]);
return obj;
}));
}).then(() => {
const query = new Parse.Query('MyClass');
const subset = children.slice(0, 5).map((child) => {
return child.id;
});
query.containedIn('child', subset);
return query.find();
}).then((results) => {
expect(results.length).toBe(5);
}).then(done).catch(done.fail);
});
it('include for specific object', function(done){
var child = new Parse.Object('Child');
var parent = new Parse.Object('Parent');