perf: Add details to error message in Parse.Query.aggregate (#9689)
This commit is contained in:
@@ -1500,4 +1500,24 @@ describe('Parse.Query Aggregate testing', () => {
|
|||||||
expect(results.length).toEqual(3);
|
expect(results.length).toEqual(3);
|
||||||
await database.adapter.deleteAllClasses(false);
|
await database.adapter.deleteAllClasses(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it_only_db('mongo')('aggregate handle mongodb errors', async () => {
|
||||||
|
const pipeline = [
|
||||||
|
{
|
||||||
|
$search: {
|
||||||
|
index: "default",
|
||||||
|
text: {
|
||||||
|
path: ["name"],
|
||||||
|
query: 'foo',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
try {
|
||||||
|
await new Parse.Query(TestObject).aggregate(pipeline);
|
||||||
|
fail();
|
||||||
|
} catch (e) {
|
||||||
|
expect(e.code).toBe(Parse.Error.INVALID_QUERY);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ const flakyTests = [
|
|||||||
"Email Verification Token Expiration: sets the _email_verify_token_expires_at and _email_verify_token fields after user SignUp",
|
"Email Verification Token Expiration: sets the _email_verify_token_expires_at and _email_verify_token fields after user SignUp",
|
||||||
// Expected 0 to be 1.
|
// Expected 0 to be 1.
|
||||||
"Email Verification Token Expiration: should send a new verification email when a resend is requested and the user is UNVERIFIED",
|
"Email Verification Token Expiration: should send a new verification email when a resend is requested and the user is UNVERIFIED",
|
||||||
|
// Expected 0 to be 1.
|
||||||
|
"Email Verification Token Expiration: should match codes with emailVerifyTokenReuseIfValid",
|
||||||
];
|
];
|
||||||
|
|
||||||
/** The minimum execution time in seconds for a test to be considered slow. */
|
/** The minimum execution time in seconds for a test to be considered slow. */
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import ClassesRouter from './ClassesRouter';
|
|||||||
import UsersRouter from './UsersRouter';
|
import UsersRouter from './UsersRouter';
|
||||||
|
|
||||||
export class AggregateRouter extends ClassesRouter {
|
export class AggregateRouter extends ClassesRouter {
|
||||||
handleFind(req) {
|
async handleFind(req) {
|
||||||
const body = Object.assign(req.body || {}, ClassesRouter.JSONFromQuery(req.query));
|
const body = Object.assign(req.body || {}, ClassesRouter.JSONFromQuery(req.query));
|
||||||
const options = {};
|
const options = {};
|
||||||
if (body.distinct) {
|
if (body.distinct) {
|
||||||
@@ -31,8 +31,8 @@ export class AggregateRouter extends ClassesRouter {
|
|||||||
if (typeof body.where === 'string') {
|
if (typeof body.where === 'string') {
|
||||||
body.where = JSON.parse(body.where);
|
body.where = JSON.parse(body.where);
|
||||||
}
|
}
|
||||||
return rest
|
try {
|
||||||
.find(
|
const response = await rest.find(
|
||||||
req.config,
|
req.config,
|
||||||
req.auth,
|
req.auth,
|
||||||
this.className(req),
|
this.className(req),
|
||||||
@@ -40,15 +40,16 @@ export class AggregateRouter extends ClassesRouter {
|
|||||||
options,
|
options,
|
||||||
req.info.clientSDK,
|
req.info.clientSDK,
|
||||||
req.info.context
|
req.info.context
|
||||||
)
|
);
|
||||||
.then(response => {
|
for (const result of response.results) {
|
||||||
for (const result of response.results) {
|
if (typeof result === 'object') {
|
||||||
if (typeof result === 'object') {
|
UsersRouter.removeHiddenProperties(result);
|
||||||
UsersRouter.removeHiddenProperties(result);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return { response };
|
}
|
||||||
});
|
return { response };
|
||||||
|
} catch (e) {
|
||||||
|
throw new Parse.Error(Parse.Error.INVALID_QUERY, e.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Builds a pipeline from the body. Originally the body could be passed as a single object,
|
/* Builds a pipeline from the body. Originally the body could be passed as a single object,
|
||||||
|
|||||||
Reference in New Issue
Block a user