Skip to content

Commit 422d1c3

Browse files
authored
Merge branch 'alpha' into testExclusionList
2 parents 853cc93 + 5462834 commit 422d1c3

File tree

5 files changed

+42
-4
lines changed

5 files changed

+42
-4
lines changed

changelogs/CHANGELOG_alpha.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# [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)
2+
3+
4+
### Bug Fixes
5+
6+
* 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))
7+
18
# [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)
29

310

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "parse-server",
3-
"version": "6.4.0-alpha.4",
3+
"version": "6.4.0-alpha.5",
44
"description": "An express module providing a Parse-compatible API server",
55
"main": "lib/index.js",
66
"repository": {

spec/CloudCode.spec.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2510,6 +2510,31 @@ describe('beforeFind hooks', () => {
25102510
expect(res2.get('pointerFieldArray')[0].get('aField')).toBe('aFieldValue');
25112511
expect(spy).toHaveBeenCalledTimes(2);
25122512
});
2513+
2514+
it('should have access to context in include query in beforeFind hook', async () => {
2515+
let beforeFindTestObjectCalled = false;
2516+
let beforeFindTestObject2Called = false;
2517+
const obj1 = new Parse.Object('TestObject');
2518+
const obj2 = new Parse.Object('TestObject2');
2519+
obj2.set('aField', 'aFieldValue');
2520+
await obj2.save();
2521+
obj1.set('pointerField', obj2);
2522+
await obj1.save();
2523+
Parse.Cloud.beforeFind('TestObject', req => {
2524+
expect(req.context).toBeDefined();
2525+
expect(req.context.a).toEqual('a');
2526+
beforeFindTestObjectCalled = true;
2527+
});
2528+
Parse.Cloud.beforeFind('TestObject2', req => {
2529+
expect(req.context).toBeDefined();
2530+
expect(req.context.a).toEqual('a');
2531+
beforeFindTestObject2Called = true;
2532+
});
2533+
const query = new Parse.Query('TestObject');
2534+
await query.include('pointerField').find({ context: { a: 'a' } });
2535+
expect(beforeFindTestObjectCalled).toBeTrue();
2536+
expect(beforeFindTestObject2Called).toBeTrue();
2537+
});
25132538
});
25142539

25152540
describe('afterFind hooks', () => {

src/RestQuery.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,7 @@ _UnsafeRestQuery.prototype.replaceInQuery = async function () {
478478
className: inQueryValue.className,
479479
restWhere: inQueryValue.where,
480480
restOptions: additionalOptions,
481+
context: this.context,
481482
});
482483
return subquery.execute().then(response => {
483484
transformInQuery(inQueryObject, subquery.className, response.results);
@@ -537,6 +538,7 @@ _UnsafeRestQuery.prototype.replaceNotInQuery = async function () {
537538
className: notInQueryValue.className,
538539
restWhere: notInQueryValue.where,
539540
restOptions: additionalOptions,
541+
context: this.context,
540542
});
541543

542544
return subquery.execute().then(response => {
@@ -609,6 +611,7 @@ _UnsafeRestQuery.prototype.replaceSelect = async function () {
609611
className: selectValue.query.className,
610612
restWhere: selectValue.query.where,
611613
restOptions: additionalOptions,
614+
context: this.context,
612615
});
613616

614617
return subquery.execute().then(response => {
@@ -671,6 +674,7 @@ _UnsafeRestQuery.prototype.replaceDontSelect = async function () {
671674
className: dontSelectValue.query.className,
672675
restWhere: dontSelectValue.query.where,
673676
restOptions: additionalOptions,
677+
context: this.context,
674678
});
675679

676680
return subquery.execute().then(response => {
@@ -860,6 +864,7 @@ _UnsafeRestQuery.prototype.handleInclude = function () {
860864
this.auth,
861865
this.response,
862866
this.include[0],
867+
this.context,
863868
this.restOptions
864869
);
865870
if (pathResponse.then) {
@@ -946,7 +951,7 @@ _UnsafeRestQuery.prototype.handleAuthAdapters = async function () {
946951
// Adds included values to the response.
947952
// Path is a list of field names.
948953
// Returns a promise for an augmented response.
949-
function includePath(config, auth, response, path, restOptions = {}) {
954+
function includePath(config, auth, response, path, context, restOptions = {}) {
950955
var pointers = findPointers(response.results, path);
951956
if (pointers.length == 0) {
952957
return response;
@@ -1026,6 +1031,7 @@ function includePath(config, auth, response, path, restOptions = {}) {
10261031
className,
10271032
restWhere: where,
10281033
restOptions: includeRestOptions,
1034+
context: context,
10291035
});
10301036
return query.execute({ op: 'get' }).then(results => {
10311037
results.className = className;

0 commit comments

Comments
 (0)