Skip to content

Commit c446d42

Browse files
authored
Merge b62ab51 into d789ca6
2 parents d789ca6 + b62ab51 commit c446d42

File tree

4 files changed

+12
-47
lines changed

4 files changed

+12
-47
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ ___
2323
- NEW: Supporting patterns in LiveQuery server's config parameter `classNames` [#7131](https://github.com/parse-community/parse-server/pull/7131). Thanks to [Nes-si](https://github.com/Nes-si)
2424
- NEW: `requireAnyUserRoles` and `requireAllUserRoles` for Parse Cloud validator. [#7097](https://github.com/parse-community/parse-server/pull/7097). Thanks to [dblythy](https://github.com/dblythy)
2525
- NEW: Support Facebook Limited Login [#7219](https://github.com/parse-community/parse-server/pull/7219). Thanks to [miguel-s](https://github.com/miguel-s)
26+
- IMPROVE: Removed Stage name check on aggregate pipelines [#7237](https://github.com/parse-community/parse-server/pull/7237). Thanks to [BRETT71](https://github.com/BRETT71)
2627
- IMPROVE: Retry transactions on MongoDB when it fails due to transient error [#7187](https://github.com/parse-community/parse-server/pull/7187). Thanks to [Antonio Davi Macedo Coelho de Castro](https://github.com/davimacedo).
2728
- IMPROVE: Bump tests to use Mongo 4.4.4 [#7184](https://github.com/parse-community/parse-server/pull/7184). Thanks to [Antonio Davi Macedo Coelho de Castro](https://github.com/davimacedo).
2829
- IMPROVE: Added new account lockout policy option `accountLockout.unlockOnPasswordReset` to automatically unlock account on password reset. [#7146](https://github.com/parse-community/parse-server/pull/7146). Thanks to [Manuel Trezza](https://github.com/mtrezza).

spec/AggregateRouter.spec.js

+11
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,15 @@ describe('AggregateRouter', () => {
7474
expect(e.message).toBe('Pipeline stages should only have one key found group, match');
7575
}
7676
});
77+
78+
it('get search pipeline from Pipeline Operator (Array)', () => {
79+
const body = {
80+
pipeline: {
81+
search: {},
82+
},
83+
};
84+
const expected = [{ $search: {} }];
85+
const result = AggregateRouter.getPipeline(body);
86+
expect(result).toEqual(expected);
87+
});
7788
});

spec/ParseQuery.Aggregate.spec.js

-12
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,6 @@ describe('Parse.Query Aggregate testing', () => {
8383
);
8484
});
8585

86-
it('invalid query invalid key', done => {
87-
const options = Object.assign({}, masterKeyOptions, {
88-
body: {
89-
unknown: {},
90-
},
91-
});
92-
get(Parse.serverURL + '/aggregate/TestObject', options).catch(error => {
93-
expect(error.error.code).toEqual(Parse.Error.INVALID_QUERY);
94-
done();
95-
});
96-
});
97-
9886
it('invalid query group _id', done => {
9987
const options = Object.assign({}, masterKeyOptions, {
10088
body: {

src/Routers/AggregateRouter.js

-35
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,6 @@ import * as middleware from '../middlewares';
44
import Parse from 'parse/node';
55
import UsersRouter from './UsersRouter';
66

7-
const BASE_KEYS = ['where', 'distinct', 'pipeline', 'hint', 'explain'];
8-
9-
const PIPELINE_KEYS = [
10-
'addFields',
11-
'bucket',
12-
'bucketAuto',
13-
'collStats',
14-
'count',
15-
'currentOp',
16-
'facet',
17-
'geoNear',
18-
'graphLookup',
19-
'group',
20-
'indexStats',
21-
'limit',
22-
'listLocalSessions',
23-
'listSessions',
24-
'lookup',
25-
'match',
26-
'out',
27-
'project',
28-
'redact',
29-
'replaceRoot',
30-
'sample',
31-
'skip',
32-
'sort',
33-
'sortByCount',
34-
'unwind',
35-
];
36-
37-
const ALLOWED_KEYS = [...BASE_KEYS, ...PIPELINE_KEYS];
38-
397
export class AggregateRouter extends ClassesRouter {
408
handleFind(req) {
419
const body = Object.assign(req.body, ClassesRouter.JSONFromQuery(req.query));
@@ -122,9 +90,6 @@ export class AggregateRouter extends ClassesRouter {
12290
}
12391

12492
static transformStage(stageName, stage) {
125-
if (ALLOWED_KEYS.indexOf(stageName) === -1) {
126-
throw new Parse.Error(Parse.Error.INVALID_QUERY, `Invalid parameter for query: ${stageName}`);
127-
}
12893
if (stageName === 'group') {
12994
if (Object.prototype.hasOwnProperty.call(stage[stageName], '_id')) {
13095
throw new Parse.Error(

0 commit comments

Comments
 (0)