Skip to content

Commit d4d455e

Browse files
authored
Merge branch 'alpha' into feat-disable-collation
2 parents ea4310d + 93af48a commit d4d455e

File tree

7 files changed

+90
-18
lines changed

7 files changed

+90
-18
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: 26 additions & 16 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/.eslintrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"equal": true,
1616
"expectAsync": true,
1717
"notEqual": true,
18+
"it_id": true,
1819
"it_only_db": true,
1920
"it_only_mongodb_version": true,
2021
"it_only_postgres_version": true,

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', () => {

spec/helper.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,29 @@ global.it_exclude_dbs = excluded => {
428428
}
429429
};
430430

431+
let testExclusionList = [];
432+
try {
433+
// Fetch test exclusion list
434+
testExclusionList = require('./testExclusionList.json');
435+
console.log(`Using test exclusion list with ${testExclusionList.length} entries`);
436+
} catch(error) {
437+
if(error.code !== 'MODULE_NOT_FOUND') {
438+
throw error;
439+
}
440+
}
441+
442+
// Disable test if its UUID is found in testExclusionList
443+
global.it_id = (id, func) => {
444+
if (testExclusionList.includes(id)) {
445+
return xit;
446+
} else {
447+
if(func === undefined)
448+
return it;
449+
else
450+
return func;
451+
}
452+
};
453+
431454
global.it_only_db = db => {
432455
if (
433456
process.env.PARSE_SERVER_TEST_DB === db ||

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)