Parse-SDK-JS
Parse-SDK-JS copied to clipboard
ParseObject.get has side effects for pending operations on nested fields
New Issue Checklist
- [x] I am not disclosing a vulnerability.
- [x] I am not just asking a question.
- [x] I have searched through existing issues.
- [x] I can reproduce the issue with the latest versions of Parse Server and the Parse JS SDK.
Issue Description
Pending operations on nested fields of depth at least two get re-done for every call to .get()
Steps to reproduce
- Create an object with a double-nested integer field:
const obj = new TestObject();
obj.set('objectField', { foo: { bar: 5 } });
- Save the object to create it:
await obj.save();
- Increment the nested field:
obj.increment('objectField.foo.bar', 15);
- Read its value twice:
assert.equal(obj.get('objectField').foo.bar, 20);
assert.equal(obj.get('objectField').foo.bar, 20);
Actual Outcome
The first assert succeeds, the second fails with 35 != 20
Note that without the call to .save(), even the first assert fails with 15 != 20, which might be a separate issue.
Expected Outcome
Both asserts should succeed
Environment
Server
- Parse Server version:
4.5.0 - Operating system:
Ubuntu 20.04 - Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc):
local
Database
- System (MongoDB or Postgres):
MongoDB - Database version:
v4.4.5 - Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc):
local
Client
- Parse JS SDK version:
masteras of 14 May
Logs
These lines should probably be doing a deep-copy. Feels like we should also remove line 138 and the spread at line 139.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Fixed after #1451