Merge pull request #925 from ParsePlatform/nlutsenko.dontSelectQueries
Do not require where clause in condition on queries.
This commit is contained in:
@@ -2,6 +2,9 @@
|
|||||||
// hungry/js/test/parse_query_test.js
|
// hungry/js/test/parse_query_test.js
|
||||||
//
|
//
|
||||||
// Some new tests are added.
|
// Some new tests are added.
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const Parse = require('parse/node');
|
||||||
|
|
||||||
describe('Parse.Query testing', () => {
|
describe('Parse.Query testing', () => {
|
||||||
it("basic query", function(done) {
|
it("basic query", function(done) {
|
||||||
@@ -1574,6 +1577,29 @@ describe('Parse.Query testing', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("dontSelect query without conditions", function(done) {
|
||||||
|
const RestaurantObject = Parse.Object.extend("Restaurant");
|
||||||
|
const PersonObject = Parse.Object.extend("Person");
|
||||||
|
const objects = [
|
||||||
|
new RestaurantObject({ location: "Djibouti" }),
|
||||||
|
new RestaurantObject({ location: "Ouagadougou" }),
|
||||||
|
new PersonObject({ name: "Bob", hometown: "Djibouti" }),
|
||||||
|
new PersonObject({ name: "Tom", hometown: "Yoloblahblahblah" }),
|
||||||
|
new PersonObject({ name: "Billy", hometown: "Ouagadougou" })
|
||||||
|
];
|
||||||
|
|
||||||
|
Parse.Object.saveAll(objects, function() {
|
||||||
|
const query = new Parse.Query(RestaurantObject);
|
||||||
|
const mainQuery = new Parse.Query(PersonObject);
|
||||||
|
mainQuery.doesNotMatchKeyInQuery("hometown", "location", query);
|
||||||
|
mainQuery.find().then(results => {
|
||||||
|
equal(results.length, 1);
|
||||||
|
equal(results[0].get('name'), 'Tom');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("object with length", function(done) {
|
it("object with length", function(done) {
|
||||||
var TestObject = Parse.Object.extend("TestObject");
|
var TestObject = Parse.Object.extend("TestObject");
|
||||||
var obj = new TestObject();
|
var obj = new TestObject();
|
||||||
|
|||||||
@@ -324,12 +324,10 @@ RestQuery.prototype.replaceDontSelect = function() {
|
|||||||
!dontSelectValue.key ||
|
!dontSelectValue.key ||
|
||||||
typeof dontSelectValue.query !== 'object' ||
|
typeof dontSelectValue.query !== 'object' ||
|
||||||
!dontSelectValue.query.className ||
|
!dontSelectValue.query.className ||
|
||||||
!dontSelectValue.query.where ||
|
|
||||||
Object.keys(dontSelectValue).length !== 2) {
|
Object.keys(dontSelectValue).length !== 2) {
|
||||||
throw new Parse.Error(Parse.Error.INVALID_QUERY,
|
throw new Parse.Error(Parse.Error.INVALID_QUERY,
|
||||||
'improper usage of $dontSelect');
|
'improper usage of $dontSelect');
|
||||||
}
|
}
|
||||||
|
|
||||||
var subquery = new RestQuery(
|
var subquery = new RestQuery(
|
||||||
this.config, this.auth, dontSelectValue.query.className,
|
this.config, this.auth, dontSelectValue.query.className,
|
||||||
dontSelectValue.query.where);
|
dontSelectValue.query.where);
|
||||||
|
|||||||
Reference in New Issue
Block a user