Remove Stage name check on aggregate pipelines (#7237)
* add search for atlas search index * added test for search in pipeline * removed stage name check in pipeline * removed spec for invalid query invalid key * updated changelog Co-authored-by: Diamond Lewis <findlewis@gmail.com>
This commit is contained in:
@@ -23,6 +23,7 @@ ___
|
|||||||
- 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)
|
- 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)
|
||||||
- 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)
|
- 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)
|
||||||
- NEW: Support Facebook Limited Login [#7219](https://github.com/parse-community/parse-server/pull/7219). Thanks to [miguel-s](https://github.com/miguel-s)
|
- NEW: Support Facebook Limited Login [#7219](https://github.com/parse-community/parse-server/pull/7219). Thanks to [miguel-s](https://github.com/miguel-s)
|
||||||
|
- 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)
|
||||||
- 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).
|
- 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).
|
||||||
- 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).
|
- 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).
|
||||||
- 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).
|
- 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).
|
||||||
|
|||||||
@@ -74,4 +74,15 @@ describe('AggregateRouter', () => {
|
|||||||
expect(e.message).toBe('Pipeline stages should only have one key found group, match');
|
expect(e.message).toBe('Pipeline stages should only have one key found group, match');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('get search pipeline from Pipeline Operator (Array)', () => {
|
||||||
|
const body = {
|
||||||
|
pipeline: {
|
||||||
|
search: {},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const expected = [{ $search: {} }];
|
||||||
|
const result = AggregateRouter.getPipeline(body);
|
||||||
|
expect(result).toEqual(expected);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -83,18 +83,6 @@ describe('Parse.Query Aggregate testing', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('invalid query invalid key', done => {
|
|
||||||
const options = Object.assign({}, masterKeyOptions, {
|
|
||||||
body: {
|
|
||||||
unknown: {},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
get(Parse.serverURL + '/aggregate/TestObject', options).catch(error => {
|
|
||||||
expect(error.error.code).toEqual(Parse.Error.INVALID_QUERY);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('invalid query group _id', done => {
|
it('invalid query group _id', done => {
|
||||||
const options = Object.assign({}, masterKeyOptions, {
|
const options = Object.assign({}, masterKeyOptions, {
|
||||||
body: {
|
body: {
|
||||||
|
|||||||
@@ -4,38 +4,6 @@ import * as middleware from '../middlewares';
|
|||||||
import Parse from 'parse/node';
|
import Parse from 'parse/node';
|
||||||
import UsersRouter from './UsersRouter';
|
import UsersRouter from './UsersRouter';
|
||||||
|
|
||||||
const BASE_KEYS = ['where', 'distinct', 'pipeline', 'hint', 'explain'];
|
|
||||||
|
|
||||||
const PIPELINE_KEYS = [
|
|
||||||
'addFields',
|
|
||||||
'bucket',
|
|
||||||
'bucketAuto',
|
|
||||||
'collStats',
|
|
||||||
'count',
|
|
||||||
'currentOp',
|
|
||||||
'facet',
|
|
||||||
'geoNear',
|
|
||||||
'graphLookup',
|
|
||||||
'group',
|
|
||||||
'indexStats',
|
|
||||||
'limit',
|
|
||||||
'listLocalSessions',
|
|
||||||
'listSessions',
|
|
||||||
'lookup',
|
|
||||||
'match',
|
|
||||||
'out',
|
|
||||||
'project',
|
|
||||||
'redact',
|
|
||||||
'replaceRoot',
|
|
||||||
'sample',
|
|
||||||
'skip',
|
|
||||||
'sort',
|
|
||||||
'sortByCount',
|
|
||||||
'unwind',
|
|
||||||
];
|
|
||||||
|
|
||||||
const ALLOWED_KEYS = [...BASE_KEYS, ...PIPELINE_KEYS];
|
|
||||||
|
|
||||||
export class AggregateRouter extends ClassesRouter {
|
export class AggregateRouter extends ClassesRouter {
|
||||||
handleFind(req) {
|
handleFind(req) {
|
||||||
const body = Object.assign(req.body, ClassesRouter.JSONFromQuery(req.query));
|
const body = Object.assign(req.body, ClassesRouter.JSONFromQuery(req.query));
|
||||||
@@ -122,9 +90,6 @@ export class AggregateRouter extends ClassesRouter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static transformStage(stageName, stage) {
|
static transformStage(stageName, stage) {
|
||||||
if (ALLOWED_KEYS.indexOf(stageName) === -1) {
|
|
||||||
throw new Parse.Error(Parse.Error.INVALID_QUERY, `Invalid parameter for query: ${stageName}`);
|
|
||||||
}
|
|
||||||
if (stageName === 'group') {
|
if (stageName === 'group') {
|
||||||
if (Object.prototype.hasOwnProperty.call(stage[stageName], '_id')) {
|
if (Object.prototype.hasOwnProperty.call(stage[stageName], '_id')) {
|
||||||
throw new Parse.Error(
|
throw new Parse.Error(
|
||||||
|
|||||||
Reference in New Issue
Block a user