-
Notifications
You must be signed in to change notification settings - Fork 1.1k
5065 empty map with document reference #5066
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
base: main
Are you sure you want to change the base?
5065 empty map with document reference #5066
Conversation
8c296c4
to
18d87d6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for taking the time to prepare this PR.
Kindly let me know if you'd like to add the tests from the review comment. If not, I can take it from here and continue the work.
@Test // GH-5065 | ||
@DisplayName("Converter should read an empty object as an empty map with a valis values property when using @DocumentReference(lazy = true).") | ||
void readsEmptyMapWithLazyLoadedDocumentReferenceCorrectly() { | ||
org.bson.Document document = org.bson.Document.parse("{\"map\":{}}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would also be interesting to have test for { 'map' : null }
expecting null
for the target.map
.
I added lower level tests in the PR that didn't require the @nonnull
annotations to test. They really only caused the issue to fail faster. I
can add a test for `{ map: null }`
…On Wed, Oct 15, 2025, 9:18 AM Christoph Strobl ***@***.***> wrote:
***@***.**** commented on this pull request.
Thank you for taking the time to prepare this PR.
Kindly let me know if you'd like to add the tests from the review comment.
If not, I can take it from here and continue the work.
------------------------------
In
spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/MappingMongoConverterTests.java
<#5066 (comment)>
:
> + EmptyMapDocument target = converter.read(EmptyMapDocument.class, document);
+ assertThat(target.map).isNotNull().isEmpty();
+ }
+
+ @test // GH-5065
+ @DisplayName("Converter should read an empty object as an empty map when using @DocumentReference.")
+ void readsEmptyMapWithDocumentReferenceCorrectly() {
+ org.bson.Document document = org.bson.Document.parse("{\"map\":{}}");
+ DocumentReferenceEmptyMapDocument target = converter.read(DocumentReferenceEmptyMapDocument.class, document);
+ assertThat(target.map).isNotNull().isEmpty();
+ }
+
+ @test // GH-5065
+ @DisplayName("Converter should read an empty object as an empty map with a valis values property when using @DocumentReference(lazy = true).")
+ void readsEmptyMapWithLazyLoadedDocumentReferenceCorrectly() {
+ org.bson.Document document = org.bson.Document.parse("{\"map\":{}}");
I think it would also be interesting to have test for { 'map' : null }
expecting null for the target.map.
—
Reply to this email directly, view it on GitHub
<#5066 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAOV6PSVBD63KGIQMSPM2OT3XZCSBAVCNFSM6AAAAACIOSR3NKVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZTGNBQGM2TINJSHE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
|
Signed-off-by: Shawn Kovalchick <[email protected]>
Signed-off-by: Shawn Kovalchick <[email protected]>
…o prevent lazy proxy handling between tests
18d87d6
to
dbda7b4
Compare
I added tests where the map is explicitly assigned null and rebased on the latest main. There is one error occurring on the null assignment to the |
Copyright date already set to 2025. No new files. No author lists in files I touched, so I left my name out.
Fixes #5065