Skip to content

Issues modifying nested objects #6455

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

Closed
mtrezza opened this issue Mar 2, 2020 · 3 comments
Closed

Issues modifying nested objects #6455

mtrezza opened this issue Mar 2, 2020 · 3 comments
Labels
type:bug Impaired feature or lacking behavior that is likely assumed

Comments

@mtrezza
Copy link
Member

mtrezza commented Mar 2, 2020

Issue Description

3 Issues, maybe related:

a) Cannot set value for key in nested object deeper than 1 level.
For example for this object:

{
    "_id": "abc123",
    "a": {
        "b": {
            "c": true
        }
    }
}

Changing key object.set("a.b.c", false); results in:

{
    "_id": "abc123",
    "a": {
        "b": false
    }
}

Changing key object.set("a.b", false); works as expected, so the bug only affects keys deeper than 1 level.

b) Cannot set value for key in nested object without affecting the whole field.
For example for this object:

{
    "_id": "abc123",
    "a": {
        "b": true,
        "x": true
    }
}

Setting object.set("a.b", false) and then saving the object updates the whole object a, not only the nested key b. If value for x changed between fetching and saving the object, the value will be overwritten. I assume the whole field of the Parse object is flagged as dirty, therefore the whole field is updated, so there may not be much we can do about this.

MongoDB allows to update only a nested key with the $set command without affecting other fields.

c) Cannot set value for excluded key.
For example for this object:

{
    "_id": "abc123",
    "a": {
        "b": true
    }
}

When fetching the object without field a no updates to that field can be saved:

const query = new Parse.Query("myClass");
query.equalTo("a.b", true);
query.select([]);
const object = await query.first();

object.set("a.b", false);
object.save();

Results in no changes to the object.

Steps to reproduce

See above.

Expected Results

a) Value for key in nested object deeper than 1 level should be set.
b) It should be possible to update only one key of a nested object without affecting other keys.
c) It should be possible to update a field value even if it was excluded.

Actual Outcome

See description.

Environment Setup

  • Server

    • parse-server version (Be specific! Don't say 'latest'.) : "3.10.0"
    • parse JS SDK: cloud code, according to parse server "3.10.0"
    • Operating System: -
    • Hardware: -
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): -
  • Database

    • MongoDB version: 4.2.3
    • Storage engine: WT
    • Hardware: -
    • Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): AWS

Logs/Trace

@acinader
Copy link
Contributor

acinader commented Mar 5, 2020

@mtrezza any interest in getting started on solving this?

some unit tests that fail on a branch with a pr would be an awesome start?

@mtrezza mtrezza added up for grabs type:bug Impaired feature or lacking behavior that is likely assumed and removed needs investigation labels Jul 3, 2020
@stale
Copy link

stale bot commented Nov 8, 2020

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 Nov 8, 2020
@mtrezza mtrezza removed the stale label Nov 8, 2020
@dplewis
Copy link
Member

dplewis commented Mar 15, 2021

Fixed via parse-community/Parse-SDK-JS#1301

@dplewis dplewis closed this as completed Mar 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Impaired feature or lacking behavior that is likely assumed
Projects
None yet
Development

No branches or pull requests

4 participants