Skip to content

Commit 434ac91

Browse files
committed
Merge branch 'master' into flovilmart.dynamicConfigMount
2 parents ab18586 + f0ebb7b commit 434ac91

File tree

7 files changed

+178
-108
lines changed

7 files changed

+178
-108
lines changed

.github/ISSUE_TEMPLATE.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
Check out [this issue](https://github.com/ParsePlatform/parse-server/issues/1271) for an ideal bug report. The closer your issue report is to that one, the more likely we are to be able to help, and the more likely we will be to fix the issue quickly!
2+
13
For implementation related questions or technical support, please refer to the [Stack Overflow](http://stackoverflow.com/questions/tagged/parse.com) and [Server Fault](https://serverfault.com/tags/parse) communities.
24

35
Make sure these boxes are checked before submitting your issue -- thanks for reporting issues back to Parse Server!

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"commander": "^2.9.0",
2727
"deepcopy": "^0.6.1",
2828
"express": "^4.13.4",
29+
"intersect": "^1.0.1",
2930
"lru-cache": "^4.0.0",
3031
"mailgun-js": "^0.7.7",
3132
"mime": "^1.3.4",

spec/ParseQuery.spec.js

+37
Original file line numberDiff line numberDiff line change
@@ -2209,4 +2209,41 @@ describe('Parse.Query testing', () => {
22092209
})
22102210
})
22112211

2212+
it('query with two OR subqueries (regression test #1259)', done => {
2213+
let relatedObject = new Parse.Object('Class2');
2214+
relatedObject.save().then(relatedObject => {
2215+
let anObject = new Parse.Object('Class1');
2216+
let relation = anObject.relation('relation');
2217+
relation.add(relatedObject);
2218+
return anObject.save();
2219+
}).then(anObject => {
2220+
let q1 = anObject.relation('relation').query();
2221+
q1.doesNotExist('nonExistantKey1');
2222+
let q2 = anObject.relation('relation').query();
2223+
q2.doesNotExist('nonExistantKey2');
2224+
let orQuery = Parse.Query.or(q1, q2).find().then(results => {
2225+
expect(results.length).toEqual(1);
2226+
expect(results[0].objectId).toEqual(q1.objectId);
2227+
done();
2228+
});
2229+
});
2230+
});
2231+
2232+
it('objectId containedIn with multiple large array', done => {
2233+
let obj = new Parse.Object('MyClass');
2234+
obj.save().then(obj => {
2235+
let longListOfStrings = [];
2236+
for (let i = 0; i < 130; i++) {
2237+
longListOfStrings.push(i.toString());
2238+
}
2239+
longListOfStrings.push(obj.id);
2240+
let q = new Parse.Query('MyClass');
2241+
q.containedIn('objectId', longListOfStrings);
2242+
q.containedIn('objectId', longListOfStrings);
2243+
return q.find();
2244+
}).then(results => {
2245+
expect(results.length).toEqual(1);
2246+
done();
2247+
});
2248+
});
22122249
});

spec/ParseRelation.spec.js

+37-33
Original file line numberDiff line numberDiff line change
@@ -248,46 +248,50 @@ describe('Parse.Relation testing', () => {
248248
});
249249
});
250250

251-
it("queries on relation fields with multiple ins", (done) => {
252-
var ChildObject = Parse.Object.extend("ChildObject");
253-
var childObjects = [];
254-
for (var i = 0; i < 10; i++) {
251+
it("queries on relation fields with multiple containedIn (regression test for #1271)", (done) => {
252+
let ChildObject = Parse.Object.extend("ChildObject");
253+
let childObjects = [];
254+
for (let i = 0; i < 10; i++) {
255255
childObjects.push(new ChildObject({x: i}));
256256
}
257257

258258
Parse.Object.saveAll(childObjects).then(() => {
259-
var ParentObject = Parse.Object.extend("ParentObject");
260-
var parent = new ParentObject();
259+
let ParentObject = Parse.Object.extend("ParentObject");
260+
let parent = new ParentObject();
261261
parent.set("x", 4);
262-
var relation = parent.relation("child");
263-
relation.add(childObjects[0]);
264-
relation.add(childObjects[1]);
265-
relation.add(childObjects[2]);
266-
var parent2 = new ParentObject();
262+
let parent1Children = parent.relation("child");
263+
parent1Children.add(childObjects[0]);
264+
parent1Children.add(childObjects[1]);
265+
parent1Children.add(childObjects[2]);
266+
let parent2 = new ParentObject();
267267
parent2.set("x", 3);
268-
var relation2 = parent2.relation("child");
269-
relation2.add(childObjects[4]);
270-
relation2.add(childObjects[5]);
271-
relation2.add(childObjects[6]);
272-
273-
var otherChild2 = parent2.relation("otherChild");
274-
otherChild2.add(childObjects[0]);
275-
otherChild2.add(childObjects[1]);
276-
otherChild2.add(childObjects[2]);
277-
278-
var parents = [];
279-
parents.push(parent);
280-
parents.push(parent2);
281-
return Parse.Object.saveAll(parents);
268+
let parent2Children = parent2.relation("child");
269+
parent2Children.add(childObjects[4]);
270+
parent2Children.add(childObjects[5]);
271+
parent2Children.add(childObjects[6]);
272+
273+
let parent2OtherChildren = parent2.relation("otherChild");
274+
parent2OtherChildren.add(childObjects[0]);
275+
parent2OtherChildren.add(childObjects[1]);
276+
parent2OtherChildren.add(childObjects[2]);
277+
278+
return Parse.Object.saveAll([parent, parent2]);
282279
}).then(() => {
283-
var query = new Parse.Query(ParentObject);
284-
var objects = [];
285-
objects.push(childObjects[0]);
286-
query.containedIn("child", objects);
287-
query.containedIn("otherChild", [childObjects[0]]);
288-
return query.find();
289-
}).then((list) => {
290-
equal(list.length, 2, "There should be 2 results");
280+
let objectsWithChild0InBothChildren = new Parse.Query(ParentObject);
281+
objectsWithChild0InBothChildren.containedIn("child", [childObjects[0]]);
282+
objectsWithChild0InBothChildren.containedIn("otherChild", [childObjects[0]]);
283+
return objectsWithChild0InBothChildren.find();
284+
}).then(objectsWithChild0InBothChildren => {
285+
//No parent has child 0 in both it's "child" and "otherChild" field;
286+
expect(objectsWithChild0InBothChildren.length).toEqual(0);
287+
}).then(() => {
288+
let objectsWithChild4andOtherChild1 = new Parse.Query(ParentObject);
289+
objectsWithChild4andOtherChild1.containedIn("child", [childObjects[4]]);
290+
objectsWithChild4andOtherChild1.containedIn("otherChild", [childObjects[1]]);
291+
return objectsWithChild4andOtherChild1.find();
292+
}).then(objects => {
293+
// parent2 has child 4 and otherChild 1
294+
expect(objects.length).toEqual(1);
291295
done();
292296
});
293297
});

spec/schemas.spec.js

+49-33
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,7 @@ describe('schemas', () => {
981981
});
982982
});
983983
});
984-
984+
985985
it('should not be able to add a field', done => {
986986
request.post({
987987
url: 'http://localhost:8378/1/schemas/AClass',
@@ -1010,7 +1010,7 @@ describe('schemas', () => {
10101010
})
10111011
})
10121012
});
1013-
1013+
10141014
it('should not be able to add a field', done => {
10151015
request.post({
10161016
url: 'http://localhost:8378/1/schemas/AClass',
@@ -1038,7 +1038,7 @@ describe('schemas', () => {
10381038
})
10391039
})
10401040
});
1041-
1041+
10421042
it('should throw with invalid userId (>10 chars)', done => {
10431043
request.post({
10441044
url: 'http://localhost:8378/1/schemas/AClass',
@@ -1056,7 +1056,7 @@ describe('schemas', () => {
10561056
done();
10571057
})
10581058
});
1059-
1059+
10601060
it('should throw with invalid userId (<10 chars)', done => {
10611061
request.post({
10621062
url: 'http://localhost:8378/1/schemas/AClass',
@@ -1074,7 +1074,7 @@ describe('schemas', () => {
10741074
done();
10751075
})
10761076
});
1077-
1077+
10781078
it('should throw with invalid userId (invalid char)', done => {
10791079
request.post({
10801080
url: 'http://localhost:8378/1/schemas/AClass',
@@ -1092,7 +1092,7 @@ describe('schemas', () => {
10921092
done();
10931093
})
10941094
});
1095-
1095+
10961096
it('should throw with invalid * (spaces)', done => {
10971097
request.post({
10981098
url: 'http://localhost:8378/1/schemas/AClass',
@@ -1110,7 +1110,7 @@ describe('schemas', () => {
11101110
done();
11111111
})
11121112
});
1113-
1113+
11141114
it('should throw with invalid * (spaces)', done => {
11151115
request.post({
11161116
url: 'http://localhost:8378/1/schemas/AClass',
@@ -1128,7 +1128,7 @@ describe('schemas', () => {
11281128
done();
11291129
})
11301130
});
1131-
1131+
11321132
it('should throw with invalid value', done => {
11331133
request.post({
11341134
url: 'http://localhost:8378/1/schemas/AClass',
@@ -1146,7 +1146,7 @@ describe('schemas', () => {
11461146
done();
11471147
})
11481148
});
1149-
1149+
11501150
it('should throw with invalid value', done => {
11511151
request.post({
11521152
url: 'http://localhost:8378/1/schemas/AClass',
@@ -1164,10 +1164,10 @@ describe('schemas', () => {
11641164
done();
11651165
})
11661166
});
1167-
1167+
11681168
function setPermissionsOnClass(className, permissions, doPut) {
11691169
let op = request.post;
1170-
if (doPut)
1170+
if (doPut)
11711171
{
11721172
op = request.put;
11731173
}
@@ -1190,18 +1190,18 @@ describe('schemas', () => {
11901190
})
11911191
});
11921192
}
1193-
1193+
11941194
it('validate CLP 1', done => {
11951195
let user = new Parse.User();
11961196
user.setUsername('user');
11971197
user.setPassword('user');
1198-
1198+
11991199
let admin = new Parse.User();
12001200
admin.setUsername('admin');
12011201
admin.setPassword('admin');
1202-
1202+
12031203
let role = new Parse.Role('admin', new Parse.ACL());
1204-
1204+
12051205
setPermissionsOnClass('AClass', {
12061206
'find': {
12071207
'role:admin': true
@@ -1239,18 +1239,18 @@ describe('schemas', () => {
12391239
done();
12401240
})
12411241
});
1242-
1242+
12431243
it('validate CLP 2', done => {
12441244
let user = new Parse.User();
12451245
user.setUsername('user');
12461246
user.setPassword('user');
1247-
1247+
12481248
let admin = new Parse.User();
12491249
admin.setUsername('admin');
12501250
admin.setPassword('admin');
1251-
1251+
12521252
let role = new Parse.Role('admin', new Parse.ACL());
1253-
1253+
12541254
setPermissionsOnClass('AClass', {
12551255
'find': {
12561256
'role:admin': true
@@ -1304,18 +1304,18 @@ describe('schemas', () => {
13041304
done();
13051305
})
13061306
});
1307-
1307+
13081308
it('validate CLP 3', done => {
13091309
let user = new Parse.User();
13101310
user.setUsername('user');
13111311
user.setPassword('user');
1312-
1312+
13131313
let admin = new Parse.User();
13141314
admin.setUsername('admin');
13151315
admin.setPassword('admin');
1316-
1316+
13171317
let role = new Parse.Role('admin', new Parse.ACL());
1318-
1318+
13191319
setPermissionsOnClass('AClass', {
13201320
'find': {
13211321
'role:admin': true
@@ -1362,18 +1362,18 @@ describe('schemas', () => {
13621362
done();
13631363
});
13641364
});
1365-
1365+
13661366
it('validate CLP 4', done => {
13671367
let user = new Parse.User();
13681368
user.setUsername('user');
13691369
user.setPassword('user');
1370-
1370+
13711371
let admin = new Parse.User();
13721372
admin.setUsername('admin');
13731373
admin.setPassword('admin');
1374-
1374+
13751375
let role = new Parse.Role('admin', new Parse.ACL());
1376-
1376+
13771377
setPermissionsOnClass('AClass', {
13781378
'find': {
13791379
'role:admin': true
@@ -1400,7 +1400,7 @@ describe('schemas', () => {
14001400
// borked CLP should not affec security
14011401
return setPermissionsOnClass('AClass', {
14021402
'found': {
1403-
'role:admin': true
1403+
'role:admin': true
14041404
}
14051405
}, true).then(() => {
14061406
fail("Should not be able to save a borked CLP");
@@ -1430,21 +1430,21 @@ describe('schemas', () => {
14301430
done();
14311431
})
14321432
});
1433-
1433+
14341434
it('validate CLP 5', done => {
14351435
let user = new Parse.User();
14361436
user.setUsername('user');
14371437
user.setPassword('user');
1438-
1438+
14391439
let user2 = new Parse.User();
14401440
user2.setUsername('user2');
14411441
user2.setPassword('user2');
14421442
let admin = new Parse.User();
14431443
admin.setUsername('admin');
14441444
admin.setPassword('admin');
1445-
1445+
14461446
let role = new Parse.Role('admin', new Parse.ACL());
1447-
1447+
14481448
Promise.resolve().then(() => {
14491449
return Parse.Object.saveAll([user, user2, admin, role], {useMasterKey: true});
14501450
}).then(()=> {
@@ -1495,5 +1495,21 @@ describe('schemas', () => {
14951495
}).then(() => {
14961496
done();
14971497
});
1498-
});
1498+
});
1499+
1500+
it('can add field as master (issue #1257)', (done) => {
1501+
setPermissionsOnClass('AClass', {
1502+
'addField': {}
1503+
}).then(() => {
1504+
var obj = new Parse.Object('AClass');
1505+
obj.set('key', 'value');
1506+
return obj.save(null, {useMasterKey: true})
1507+
}).then((obj) => {
1508+
expect(obj.get('key')).toEqual('value');
1509+
done();
1510+
}, (err) => {
1511+
fail('should not fail');
1512+
done();
1513+
});
1514+
})
14991515
});

0 commit comments

Comments
 (0)