|
61 | 61 | import org.springframework.data.mongodb.core.query.Criteria; |
62 | 62 | import org.springframework.data.mongodb.core.query.Query; |
63 | 63 | import org.springframework.data.mongodb.core.query.TextQuery; |
| 64 | +import org.springframework.data.mongodb.core.query.Update; |
64 | 65 |
|
65 | 66 | import com.mongodb.BasicDBObject; |
66 | 67 | import com.mongodb.MongoClientSettings; |
@@ -1354,6 +1355,25 @@ void mapStringIdFieldProjection() { |
1354 | 1355 | org.bson.Document mappedFields = mapper.getMappedFields(new org.bson.Document("id", 1), context.getPersistentEntity(WithStringId.class)); |
1355 | 1356 | assertThat(mappedFields).containsEntry("_id", 1); |
1356 | 1357 | } |
| 1358 | + |
| 1359 | + @Test |
| 1360 | + void mapNestedStringFieldCorrectly() { |
| 1361 | + Update update = new Update(); |
| 1362 | + update.set("levelOne.a.b.d", "e"); |
| 1363 | + org.bson.Document document = mapper.getMappedObject(update.getUpdateObject(), |
| 1364 | + context.getPersistentEntity(EntityWithNestedMap.class)); |
| 1365 | + assertThat(document).isEqualTo(new org.bson.Document("$set",new org.bson.Document("levelOne.a.b.d","e"))); |
| 1366 | + } |
| 1367 | + |
| 1368 | + @Test |
| 1369 | + void mapNestedIntegerFieldCorrectly() { |
| 1370 | + Update update = new Update(); |
| 1371 | + update.set("levelOne.0.1.3", "4"); |
| 1372 | + org.bson.Document document = mapper.getMappedObject(update.getUpdateObject(), |
| 1373 | + context.getPersistentEntity(EntityWithNestedMap.class)); |
| 1374 | + assertThat(document).isEqualTo(new org.bson.Document("$set",new org.bson.Document("levelOne.0.1.3","4"))); |
| 1375 | + } |
| 1376 | + |
1357 | 1377 |
|
1358 | 1378 | @Test // GH-3783 |
1359 | 1379 | void retainsId$InWithStringArray() { |
@@ -1542,6 +1562,11 @@ static class EntityWithIntKeyedMapOfMap{ |
1542 | 1562 | static class EntityWithComplexValueTypeList { |
1543 | 1563 | List<SimpleEntityWithoutId> list; |
1544 | 1564 | } |
| 1565 | + |
| 1566 | + static class EntityWithNestedMap { |
| 1567 | + Map<String, Map<String, Map<String, Object>>> levelOne; |
| 1568 | + } |
| 1569 | + |
1545 | 1570 |
|
1546 | 1571 | static class WithExplicitTargetTypes { |
1547 | 1572 |
|
|
0 commit comments