Skip to content

Commit

Permalink
Merge branch 'testExclusionList' of github.com:ddrechse/parse-server …
Browse files Browse the repository at this point in the history
…into testExclusionList
  • Loading branch information
ddrechse committed Oct 17, 2023
2 parents 5b053d2 + 422d1c3 commit 9067f1d
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 4 deletions.
7 changes: 7 additions & 0 deletions changelogs/CHANGELOG_alpha.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# [6.4.0-alpha.5](https://github.com/parse-community/parse-server/compare/6.4.0-alpha.4...6.4.0-alpha.5) (2023-10-14)


### Bug Fixes

* Context not passed to Cloud Code Trigger `beforeFind` when using `Parse.Query.include` ([#8765](https://github.com/parse-community/parse-server/issues/8765)) ([7d32d89](https://github.com/parse-community/parse-server/commit/7d32d8934f3ae7af7a7d8b9cc6a829c7d73973d3))

# [6.4.0-alpha.4](https://github.com/parse-community/parse-server/compare/6.4.0-alpha.3...6.4.0-alpha.4) (2023-09-29)


Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "parse-server",
"version": "6.4.0-alpha.4",
"version": "6.4.0-alpha.5",
"description": "An express module providing a Parse-compatible API server",
"main": "lib/index.js",
"repository": {
Expand Down
25 changes: 25 additions & 0 deletions spec/CloudCode.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2510,6 +2510,31 @@ describe('beforeFind hooks', () => {
expect(res2.get('pointerFieldArray')[0].get('aField')).toBe('aFieldValue');
expect(spy).toHaveBeenCalledTimes(2);
});

it('should have access to context in include query in beforeFind hook', async () => {
let beforeFindTestObjectCalled = false;
let beforeFindTestObject2Called = false;
const obj1 = new Parse.Object('TestObject');
const obj2 = new Parse.Object('TestObject2');
obj2.set('aField', 'aFieldValue');
await obj2.save();
obj1.set('pointerField', obj2);
await obj1.save();
Parse.Cloud.beforeFind('TestObject', req => {
expect(req.context).toBeDefined();
expect(req.context.a).toEqual('a');
beforeFindTestObjectCalled = true;
});
Parse.Cloud.beforeFind('TestObject2', req => {
expect(req.context).toBeDefined();
expect(req.context.a).toEqual('a');
beforeFindTestObject2Called = true;
});
const query = new Parse.Query('TestObject');
await query.include('pointerField').find({ context: { a: 'a' } });
expect(beforeFindTestObjectCalled).toBeTrue();
expect(beforeFindTestObject2Called).toBeTrue();
});
});

describe('afterFind hooks', () => {
Expand Down
8 changes: 7 additions & 1 deletion src/RestQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ _UnsafeRestQuery.prototype.replaceInQuery = async function () {
className: inQueryValue.className,
restWhere: inQueryValue.where,
restOptions: additionalOptions,
context: this.context,
});
return subquery.execute().then(response => {
transformInQuery(inQueryObject, subquery.className, response.results);
Expand Down Expand Up @@ -537,6 +538,7 @@ _UnsafeRestQuery.prototype.replaceNotInQuery = async function () {
className: notInQueryValue.className,
restWhere: notInQueryValue.where,
restOptions: additionalOptions,
context: this.context,
});

return subquery.execute().then(response => {
Expand Down Expand Up @@ -609,6 +611,7 @@ _UnsafeRestQuery.prototype.replaceSelect = async function () {
className: selectValue.query.className,
restWhere: selectValue.query.where,
restOptions: additionalOptions,
context: this.context,
});

return subquery.execute().then(response => {
Expand Down Expand Up @@ -671,6 +674,7 @@ _UnsafeRestQuery.prototype.replaceDontSelect = async function () {
className: dontSelectValue.query.className,
restWhere: dontSelectValue.query.where,
restOptions: additionalOptions,
context: this.context,
});

return subquery.execute().then(response => {
Expand Down Expand Up @@ -860,6 +864,7 @@ _UnsafeRestQuery.prototype.handleInclude = function () {
this.auth,
this.response,
this.include[0],
this.context,
this.restOptions
);
if (pathResponse.then) {
Expand Down Expand Up @@ -946,7 +951,7 @@ _UnsafeRestQuery.prototype.handleAuthAdapters = async function () {
// Adds included values to the response.
// Path is a list of field names.
// Returns a promise for an augmented response.
function includePath(config, auth, response, path, restOptions = {}) {
function includePath(config, auth, response, path, context, restOptions = {}) {
var pointers = findPointers(response.results, path);
if (pointers.length == 0) {
return response;
Expand Down Expand Up @@ -1026,6 +1031,7 @@ function includePath(config, auth, response, path, restOptions = {}) {
className,
restWhere: where,
restOptions: includeRestOptions,
context: context,
});
return query.execute({ op: 'get' }).then(results => {
results.className = className;
Expand Down

0 comments on commit 9067f1d

Please sign in to comment.