* Adds repro for #2221 * Fixes nested or queries * not for PG yet
This commit is contained in:
@@ -2529,4 +2529,30 @@ describe('Parse.Query testing', () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it_exclude_dbs(['postgres'])('properly handles nested ors', function(done) {
|
||||||
|
var objects = [];
|
||||||
|
while(objects.length != 4) {
|
||||||
|
var obj = new Parse.Object('Object');
|
||||||
|
obj.set('x', objects.length);
|
||||||
|
objects.push(obj)
|
||||||
|
}
|
||||||
|
Parse.Object.saveAll(objects).then(() => {
|
||||||
|
let q0 = new Parse.Query('Object');
|
||||||
|
q0.equalTo('x', 0);
|
||||||
|
let q1 = new Parse.Query('Object');
|
||||||
|
q1.equalTo('x', 1);
|
||||||
|
let q2 = new Parse.Query('Object');
|
||||||
|
q2.equalTo('x', 2);
|
||||||
|
let or01 = Parse.Query.or(q0,q1);
|
||||||
|
return Parse.Query.or(or01, q2).find();
|
||||||
|
}).then((results) => {
|
||||||
|
expect(results.length).toBe(3);
|
||||||
|
done();
|
||||||
|
}).catch((error) => {
|
||||||
|
fail('should not fail');
|
||||||
|
console.error(error);
|
||||||
|
done();
|
||||||
|
})
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -540,8 +540,10 @@ DatabaseController.prototype.reduceInRelation = function(className, query, schem
|
|||||||
return Promise.all(ors.map((aQuery, index) => {
|
return Promise.all(ors.map((aQuery, index) => {
|
||||||
return this.reduceInRelation(className, aQuery, schema).then((aQuery) => {
|
return this.reduceInRelation(className, aQuery, schema).then((aQuery) => {
|
||||||
query['$or'][index] = aQuery;
|
query['$or'][index] = aQuery;
|
||||||
})
|
});
|
||||||
}));
|
})).then(() => {
|
||||||
|
return Promise.resolve(query);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let promises = Object.keys(query).map((key) => {
|
let promises = Object.keys(query).map((key) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user