-
Notifications
You must be signed in to change notification settings - Fork 563
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
Fields named "id" in nested MongoDB objects are not updated by PUT requests #2280
Comments
Would you mind trying the latest snapshots? I wonder if the fix for #2287 fixes this issue here as well? |
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed. |
@odrotbohm I've tested this issue against the now-released version 4.1.4 for the |
Any chance you can bundle this up into a minimal reproducer? |
Sure; I basically have one locally already. It might be a day or two before I can get to it. |
PUT requests for nested MongoDB objects with an exposed "id" field update other fields in the nested objects, but not the "id" field. This is true for lists of nested objects, and as of Spring Data REST 4.0.3 (due I think to #2174) for directly nested objects.
This feels like it's in a similar vein to spring-projects/spring-data-mongodb#3351, in that nested MongoDB objects aren't really themselves entities, but Spring Data MongoDB & Spring Data REST treat them as such.
I ran across this issue when upgrading a project from Spring Boot 2.7.4 to 3.1.1, since Spring Data REST changed non-list nested object behavior, changing the existing behavior of the application.
Example
Build
build.gradle
Application
Tests
=>
=>
Workaround
One workaround I've discovered is to rename the
id
field but keep thegetId()
method, marking it as@Transient
.The text was updated successfully, but these errors were encountered: