Closed
Description
New Issue Checklist
- I am not disclosing a vulnerability.
- I am not just asking a question.
- I have searched through existing issues.
- I can reproduce the issue with the latest version of Parse Server.
Issue Description
With the way Parse handles pointers, if you set a query a Parse.Object and set it to req.object
using afterFind or afterLiveQueryEvent, Parse converts it to a pointer and strips all fields.
Steps to reproduce
afterFind:
it('can set a pointer object in afterFind', async done => {
//save obj for query
const obj = new Parse.Object('MyObject');
await obj.save();
Parse.Cloud.afterFind('MyObject', async ({objects}) => {
const otherObject = new Parse.Object('Test');
otherObject.set('foo', 'bar');
await otherObject.save();
// set object
objects[0].set('Pointer', otherObject);
// set first object field 'Pointer' to object
expect(objects[0].get('Pointer').get('foo')).toBe('bar');
return objects;
});
const query = new Parse.Query('MyObject');
query.equalTo('objectId', obj.id);
const [obj2] = await query.find();
const pointer = obj2.get('Pointer');
expect(pointer.get('foo')).toBe('bar');
// should be able to access 'foo' on the pointer, but it returns null.
done()
});
afterLiveQueryEvent:
Parse.Cloud.afterLiveQueryEvent('TestObject', async ({object}) => {
const query = new Parse.Query('Test2');
const obj = await query.first();
object.set('obj', obj);
});
subscription.on('update', (object) => {
expect(object.get('obj')).toBeDefined();
expect(object.get('obj').get('foo')).toBe('bar');
// foo will be null
done();
});
Actual Outcome
Fields on pointer objects are empty
Expected Outcome
Data should propagate down
Failing Test Case / Pull Request
- 🤩 I submitted a PR with a fix and a test case.
- 🧐 I submitted a PR with a failing test case.
Environment
Server
- Parse Server version:
FILL_THIS_OUT
- Operating system:
FILL_THIS_OUT
- Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc):
FILL_THIS_OUT
Database
- System (MongoDB or Postgres):
FILL_THIS_OUT
- Database version:
FILL_THIS_OUT
- Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc):
FILL_THIS_OUT
Client
- SDK (iOS, Android, JavaScript, PHP, Unity, etc):
FILL_THIS_OUT
- SDK version:
FILL_THIS_OUT