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

Partial update (PATCH) of an object replaces data #351

Closed
SilviaAmAm opened this issue Dec 1, 2023 · 1 comment · Fixed by #352
Closed

Partial update (PATCH) of an object replaces data #351

SilviaAmAm opened this issue Dec 1, 2023 · 1 comment · Fixed by #352
Assignees

Comments

@SilviaAmAm
Copy link

SilviaAmAm commented Dec 1, 2023

After creating an object with multiple properties in the "data" field, doing a PATCH call to update one of the properties in data overwrites the whole data field.

Steps to reproduce

(with a fake URL for the environment, but tested on our test environment)

  1. Create an object: POST https://objecten.test.nl/api/v2/objects
{
    "type": "https://objecttypen.test.nl/api/v2/objecttypes/2360a778-6747-47b4-ad2b-e5e281336bba",
    "record": {
        "typeVersion": 2,
        "data": {
            "type": "Fruitteelt",
            "leeftijd": 100,
            "kiemjaar": 2002
        },
        "geometry": {
            "type": "Point",
            "coordinates": [
                4.766006469726562,
                52.29066294826172
            ]
        },
        "startAt": "2023-12-01"
    }
}
  1. Update the object (PATCH https://objecten.test.nl/api/v2/objects/19fadf7f-5695-41a1-9de8-a7246b1c28a3)
{
    "record": {
        "data": {
            "kiemjaar": 2012
        },
        "startAt": "2023-12-01"
    }
}

This then returns the following object:

{
    "url": "https://objecten.test.nl/api/v2/objects/19fadf7f-5695-41a1-9de8-a7246b1c28a3",
    "uuid": "19fadf7f-5695-41a1-9de8-a7246b1c28a3",
    "type": "https://objecttypen.test.nl/api/v2/objecttypes/2360a778-6747-47b4-ad2b-e5e281336bba",
    "record": {
        "index": 2,
        "typeVersion": 2,
        "data": {
            "kiemjaar": 2012
        },
        "geometry": null,
        "startAt": "2023-12-01",
        "endAt": null,
        "registrationAt": "2023-12-01",
        "correctionFor": null,
        "correctedBy": null
    }
}

The data field is missing the type and the leeftijd attributes that were set when first creating the object.

@joeribekker
Copy link
Member

joeribekker commented Dec 4, 2023

Refinement:

Discussion involves:

Add support for Content-Type: application/merge-patch+json to merge the "data"

Or, we treat this like a bug and change the patch behaviour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants