Skip to content

Object column not updating properly #4808

Closed
@jaeggerr

Description

@jaeggerr

Issue Description

Columns of type Object (JSON object) from Parse classes are not updating properly.
New and previous values are merged.

Steps to reproduce

I'm using the Parse dashboard but this also happens in code.

  1. Create a Parse class with a field of type Object.
  2. Add a new row
  3. Set any JSON value in the field.
    { "a": "b" }
  4. Replace the value by an empty JSON object
    {}
  5. Replace the value by a JSON object with other key / values.
    { "c": "d" }

Expected Results

Object field should be replaced by the provided values.

  1. New value should be {}
  2. New value should be { "c": "d" }

Actual Outcome

  1. Value will still be { "a": "b" }.
  2. Old and new values will be merged. {"a": "b", "c": "d" }

Environment Setup

  • Server

    • parse-server version (Be specific! Don't say 'latest'.) : 2.8.2
    • Operating System: Mac OS 10.13.5
    • Hardware: Mac Mini
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): Localhost
  • Database

    • Postgres version: 10.3
    • Hardware: Mac Mini
    • Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): Localhost

Logs/Trace

verbose: REQUEST for [PUT] /parse/classes/MyClass/zHsUsMqd8t: {
"te": {
"a": "b"
}
} method=PUT, url=/parse/classes/MyClass/zHsUsMqd8t, host=localhost:1337, user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:60.0) Gecko/20100101 Firefox/60.0, accept=/, accept-language=fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3, accept-encoding=gzip, deflate, referer=http://0.0.0.0:4040/apps/TestApp%20Server/browser/MyClass, content-type=text/plain, content-length=164, origin=http://0.0.0.0:4040, connection=keep-alive, client-ip=::1, a=b
debug: PG: findOneAndUpdate MyClass { objectId: 'zHsUsMqd8t' } a=b, updatedAt=2018-06-05T15:57:32.856Z
debug: PG: updateObjectsByQuery MyClass { objectId: 'zHsUsMqd8t' } a=b, updatedAt=2018-06-05T15:57:32.856Z
debug: PG: update: UPDATE $1:name SET $2:name = ( COALESCE($2:name, '{}'::jsonb) || $3::jsonb ),$4:name = $5 WHERE $6:name = $7 RETURNING * 0=MyClass, 1=te, 2={"a":"b"}, 3=updatedAt, 4=2018-06-05T15:57:32.856Z, 5=objectId, 6=zHsUsMqd8t
verbose: RESPONSE from [PUT] /parse/classes/MyClass/zHsUsMqd8t: {
"response": {
"updatedAt": "2018-06-05T15:57:32.856Z"
}
} updatedAt=2018-06-05T15:57:32.856Z
verbose: REQUEST for [PUT] /parse/classes/MyClass/zHsUsMqd8t: {
"te": {}
} method=PUT, url=/parse/classes/MyClass/zHsUsMqd8t, host=localhost:1337, user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:60.0) Gecko/20100101 Firefox/60.0, accept=/, accept-language=fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3, accept-encoding=gzip, deflate, referer=http://0.0.0.0:4040/apps/TestApp%20Server/browser/MyClass, content-type=text/plain, content-length=157, origin=http://0.0.0.0:4040, connection=keep-alive, client-ip=::1,
debug: PG: findOneAndUpdate MyClass { objectId: 'zHsUsMqd8t' } , updatedAt=2018-06-05T15:57:37.445Z
debug: PG: updateObjectsByQuery MyClass { objectId: 'zHsUsMqd8t' } , updatedAt=2018-06-05T15:57:37.445Z
debug: PG: update: UPDATE $1:name SET $2:name = ( COALESCE($2:name, '{}'::jsonb) || $3::jsonb ),$4:name = $5 WHERE $6:name = $7 RETURNING * 0=MyClass, 1=te, 2={}, 3=updatedAt, 4=2018-06-05T15:57:37.445Z, 5=objectId, 6=zHsUsMqd8t
verbose: RESPONSE from [PUT] /parse/classes/MyClass/zHsUsMqd8t: {
"response": {
"updatedAt": "2018-06-05T15:57:37.445Z"
}
} updatedAt=2018-06-05T15:57:37.445Z
verbose: REQUEST for [PUT] /parse/classes/MyClass/zHsUsMqd8t: {
"te": {
"c": "d"
}
} method=PUT, url=/parse/classes/MyClass/zHsUsMqd8t, host=localhost:1337, user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:60.0) Gecko/20100101 Firefox/60.0, accept=/, accept-language=fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3, accept-encoding=gzip, deflate, referer=http://0.0.0.0:4040/apps/TestApp%20Server/browser/MyClass, content-type=text/plain, content-length=164, origin=http://0.0.0.0:4040, connection=keep-alive, client-ip=::1, c=d
debug: PG: findOneAndUpdate MyClass { objectId: 'zHsUsMqd8t' } c=d, updatedAt=2018-06-05T15:57:41.848Z
debug: PG: updateObjectsByQuery MyClass { objectId: 'zHsUsMqd8t' } c=d, updatedAt=2018-06-05T15:57:41.848Z
debug: PG: update: UPDATE $1:name SET $2:name = ( COALESCE($2:name, '{}'::jsonb) || $3::jsonb ),$4:name = $5 WHERE $6:name = $7 RETURNING * 0=MyClass, 1=te, 2={"c":"d"}, 3=updatedAt, 4=2018-06-05T15:57:41.848Z, 5=objectId, 6=zHsUsMqd8t
verbose: RESPONSE from [PUT] /parse/classes/MyClass/zHsUsMqd8t: {
"response": {
"updatedAt": "2018-06-05T15:57:41.848Z"
}
} updatedAt=2018-06-05T15:57:41.848Z

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions