Skip to content

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

Closed
@mstniy

Description

@mstniy

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bounty:$20Bounty applies for fixing this issue (Parse Bounty Program)type:bugImpaired feature or lacking behavior that is likely assumed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions