DATAMONGO-1904 - Fixed handling of nested arrays on reads in MappingMongoConverter.
We now properly forward the component type information into recursive calls to MappingMongoConverter.readCollectionOrArray(…).
This commit is contained in:
@@ -982,7 +982,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (dbObjItem instanceof List) {
|
if (dbObjItem instanceof List) {
|
||||||
items.add(readCollectionOrArray(ClassTypeInformation.OBJECT, (List) dbObjItem, path));
|
items.add(readCollectionOrArray(componentType, (List) dbObjItem, path));
|
||||||
} else {
|
} else {
|
||||||
items.add(getPotentiallyConvertedSimpleRead(dbObjItem, rawComponentType));
|
items.add(getPotentiallyConvertedSimpleRead(dbObjItem, rawComponentType));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1873,6 +1873,19 @@ public class MappingMongoConverterUnitTests {
|
|||||||
assertThat(result.property).isEqualTo(InterfacedEnum.INSTANCE);
|
assertThat(result.property).isEqualTo(InterfacedEnum.INSTANCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test // DATAMONGO-1904
|
||||||
|
public void readsNestedArraysCorrectly() {
|
||||||
|
|
||||||
|
List<List<List<Float>>> floats = Arrays.asList(Arrays.asList(Arrays.asList(1.0f, 2.0f)));
|
||||||
|
|
||||||
|
org.bson.Document document = new org.bson.Document("nestedFloats", floats);
|
||||||
|
|
||||||
|
WithNestedLists result = converter.read(WithNestedLists.class, document);
|
||||||
|
|
||||||
|
assertThat(result.nestedFloats).hasSize(1);
|
||||||
|
assertThat(result.nestedFloats).isEqualTo(new float[][][] { { { 1.0f, 2.0f } } });
|
||||||
|
}
|
||||||
|
|
||||||
static class GenericType<T> {
|
static class GenericType<T> {
|
||||||
T content;
|
T content;
|
||||||
}
|
}
|
||||||
@@ -2247,4 +2260,10 @@ public class MappingMongoConverterUnitTests {
|
|||||||
static class DocWithInterfacedEnum {
|
static class DocWithInterfacedEnum {
|
||||||
SomeInterface property;
|
SomeInterface property;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DATAMONGO-1904
|
||||||
|
|
||||||
|
static class WithNestedLists {
|
||||||
|
float[][][] nestedFloats;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user