Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ParseObject.get has side effects for pending operations on nested fields #1365

Closed
4 tasks done
mstniy opened this issue May 14, 2021 · 3 comments · Fixed by #1451
Closed
4 tasks done

ParseObject.get has side effects for pending operations on nested fields #1365

mstniy opened this issue May 14, 2021 · 3 comments · Fixed by #1451
Labels
bounty:$20 Bounty applies for fixing this issue (Parse Bounty Program) type:bug Impaired feature or lacking behavior that is likely assumed

Comments

@mstniy
Copy link
Contributor

mstniy commented May 14, 2021

New Issue Checklist

Issue Description

Pending operations on nested fields of depth at least two get re-done for every call to .get()

Steps to reproduce

  1. Create an object with a double-nested integer field:
const obj = new TestObject();
obj.set('objectField', { foo: { bar: 5 } });
  1. Save the object to create it:
await obj.save();
  1. Increment the nested field:
obj.increment('objectField.foo.bar', 15);
  1. 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: master as of 14 May

Logs

@mstniy
Copy link
Contributor Author

mstniy commented May 14, 2021

These lines should probably be doing a deep-copy.
Feels like we should also remove line 138 and the spread at line 139.

@stale
Copy link

stale bot commented Jul 21, 2021

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.

@stale stale bot added the stale label Jul 21, 2021
@mtrezza mtrezza removed the stale label Oct 5, 2021
@mtrezza mtrezza added state:needs-investigation type:bug Impaired feature or lacking behavior that is likely assumed bounty:$20 Bounty applies for fixing this issue (Parse Bounty Program) and removed state:needs-investigation labels Oct 21, 2021
@mstniy
Copy link
Contributor Author

mstniy commented May 1, 2024

Fixed after #1451

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bounty:$20 Bounty applies for fixing this issue (Parse Bounty Program) type:bug Impaired feature or lacking behavior that is likely assumed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants