spring-projects / spring-projects/spring-data-rest

Explicitly supplying null value on PATCH does not get applied [DATAREST-342]

Open
#724 4 comments 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Dec 31, 2020.

type: bug
Dominant language
Java
Stars
958
Forks
568
PR merge metrics
No merged PRs in 30d

Description

Aaron Loes opened DATAREST-342 and commented

Given an existing farm:

{
  "name" : "Old Macdonalds Farm",
  "_links" : {
    "self" : {
      "href" : "http://localhost:8080/farms/1"
    },
    "animals" : {
      "href" : "http://localhost:8080/farms/1/animals"
    }
  }
}

If i were to perform a PATCH where i would want to empty out our farms name:

{
  "name" : null
}

this change will not get applied due to the null checking in DomainObjectMerger:

{
  "name" : "Old Macdonalds Farm",
  "_links" : {
    "self" : {
      "href" : "http://localhost:8080/farms/1"
    },
    "animals" : {
      "href" : "http://localhost:8080/farms/1/animals"
    }
  }
}

To me this is wrong because i've made an explicit decision to null out a value and it will not be applied


Affects: 2.1.1 (Dijkstra SR1)

3 votes, 3 watchers

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.