[DATAREST-1338] JSON patch doesn't update single Map's values Created: 18/Jan/19 Updated: 07/Mar/19 Resolved: 05/Mar/19
|Project:||Spring Data REST|
|Fix Version/s:||3.2 M2 (Moore), 3.1.6 (Lovelace SR6)|
|Reporter:||Luca Cherubin||Assignee:||Oliver Drotbohm|
|Remaining Estimate:||Not Specified|
|Time Spent:||Not Specified|
|Original Estimate:||Not Specified|
|Pull Request URL:||https://github.com/spring-projects/spring-data-rest/pull/305|
Steps to reproduce:
Here I create JSON patches
Here the kind of operations that I would expect to work but do not work
|Comment by Oliver Drotbohm [ 18/Jan/19 ]|
You're right, it's currently a limitation in our to SpEL translations. It's particularly tricky as we have to but by definition cannot statically verify the paths containing a Map traversal as it needs an object instance to be verified on. Our current verification algorithm can safely identify collection traversals as it can inspect numbers. For maps however it's not clear whether a segment is a map key until we bind the path against a type.
It looks like we need to improve TypedSpelPath.verifyPath(…) to not choke on the map key segment and TypedSpelPath(SpelPath, Class<?>) to rebuild the expression based on the type information so that segments are translated into map keys properly.
|Comment by Oliver Drotbohm [ 29/Jan/19 ]|
Should be back-portable to 3.1 and 3.0 (latter optional).
|Comment by mle-enso [ 06/Feb/19 ]|
Wonderful, just verified this for our use-case to PATCH an entity like:
with the following change:
…which did not work before.
|Comment by Oliver Drotbohm [ 05/Mar/19 ]|
That's now merged for inclusion in Spring Data Moore M2 and Lovelace SR6. Backport to Kay unfortunately didn't work as the implementation was using API implemented in Spring Data Commons in Lovelace only.