From b514d7372a51c30440d03b7c908a2d1fbde1ba13 Mon Sep 17 00:00:00 2001 From: Kartal Kaan Bozdogan Date: Wed, 3 Jan 2024 13:41:36 +0100 Subject: [PATCH] Fix cloud functions rejecting Parse pointers inside arrays --- spec/CloudCode.spec.js | 12 ++++++++++++ src/Routers/FunctionsRouter.js | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/spec/CloudCode.spec.js b/spec/CloudCode.spec.js index a1c8b48bfd..5cc8950a01 100644 --- a/spec/CloudCode.spec.js +++ b/spec/CloudCode.spec.js @@ -2012,6 +2012,18 @@ describe('cloud functions', () => { Parse.Cloud.run('myFunction', {}).then(() => done()); }); + + it('can pass Parse pointers inside arrays', async () => { + Parse.Cloud.define('test', function () { + return 42; + }); + + expect( + await Parse.Cloud.run('test', { + a: [{ __type: 'Pointer', className: 'foo', objectId: 'foo' }], + }) + ).toEqual(42); + }); }); describe('beforeSave hooks', () => { diff --git a/src/Routers/FunctionsRouter.js b/src/Routers/FunctionsRouter.js index bb4b959ebe..eab76eeb1b 100644 --- a/src/Routers/FunctionsRouter.js +++ b/src/Routers/FunctionsRouter.js @@ -12,7 +12,7 @@ import { logger } from '../logger'; function parseObject(obj, config) { if (Array.isArray(obj)) { return obj.map(item => { - return parseObject(item); + return parseObject(item, config); }); } else if (obj && obj.__type == 'Date') { return Object.assign(new Date(obj.iso), obj);