Adding $nor operator support (#4768)

* adding nor to specialQuerykeys

* adding nor suport

* adding test

* CRLF

* adding postgres NOR

* adding nor validation

* adding NOR test

* adding test amd fixing NOR cases

* revert the nor logic
This commit is contained in:
Jérémy Piednoel
2018-05-18 15:26:33 -04:00
committed by Diamond Lewis
parent a9ebc2b9af
commit 77ed10f57b
4 changed files with 74 additions and 6 deletions

View File

@@ -2567,6 +2567,63 @@ describe('Parse.Query testing', () => {
});
});
it('$nor valid query', (done) => {
const objects = Array.from(Array(10).keys()).map((rating) => {
return new TestObject({ 'rating': rating });
});
const highValue = 5;
const lowValue = 3;
const options = Object.assign({}, masterKeyOptions, {
body: {
where: {
$nor: [
{ rating : { $gt : highValue } },
{ rating : { $lte : lowValue } },
]
},
}
});
Parse.Object.saveAll(objects).then(() => {
return rp.get(Parse.serverURL + "/classes/TestObject", options);
}).then((results) => {
expect(results.results.length).toBe(highValue - lowValue);
expect(results.results.every(res => res.rating > lowValue && res.rating <= highValue)).toBe(true);
done();
});
});
it('$nor invalid query - empty array', (done) => {
const options = Object.assign({}, masterKeyOptions, {
body: {
where: { $nor: [] },
}
});
const obj = new TestObject();
obj.save().then(() => {
return rp.get(Parse.serverURL + "/classes/TestObject", options);
}).then(done.fail).catch((error) => {
equal(error.error.code, Parse.Error.INVALID_QUERY);
done();
});
});
it('$nor invalid query - wrong type', (done) => {
const options = Object.assign({}, masterKeyOptions, {
body: {
where: { $nor: 1337 },
}
});
const obj = new TestObject();
obj.save().then(() => {
return rp.get(Parse.serverURL + "/classes/TestObject", options);
}).then(done.fail).catch((error) => {
equal(error.error.code, Parse.Error.INVALID_QUERY);
done();
});
});
it("dontSelect query", function(done) {
const RestaurantObject = Parse.Object.extend("Restaurant");
const PersonObject = Parse.Object.extend("Person");