spring-data-rest icon indicating copy to clipboard operation
spring-data-rest copied to clipboard

repro(patch): test case for adding an item to the end of an array

Open Allsimon opened this issue 7 years ago • 3 comments

(Sorry I can't login on Jira ATM, I'll create the ticket there as soon as it's working again)

Currently: adding an item with the index equals to the number of elements in the list throws org.springframework.expression.spel.SpelEvaluationException: EL1025E: The collection has '1' elements, index '1' is invalid

For example (in pseudo-code):

let object = {foo: ["Hello"]};

let addOperation = {"op": "add", "path": "/foo/1", "value": "world!"};

addOperation.perform(object);

is a valid JSON Patch operation but throws with Spring

See the RFC:

   o  An element to add to an existing array - whereupon the supplied
      value is added to the array at the indicated location.  Any
      elements at or above the specified index are shifted one position
      to the right.  The specified index MUST NOT be greater than the
      number of elements in the array.  If the "-" character is used to
      index the end of the array (see [RFC6901]), this has the effect of
      appending the value to the array.

Allsimon avatar Jul 26 '18 12:07 Allsimon

@Allsimon Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

pivotal-issuemaster avatar Jul 26 '18 12:07 pivotal-issuemaster

@Allsimon Thank you for signing the Contributor License Agreement!

pivotal-issuemaster avatar Jul 26 '18 12:07 pivotal-issuemaster

I've created DATAREST-1273.

odrotbohm avatar Aug 06 '18 12:08 odrotbohm