DATAMONGO-2633 - Fix json parsing of nested arrays in ParameterBindingDocumentCodec.
Original pull request: #888.
This commit is contained in:
committed by
Mark Paluch
parent
91c39e2825
commit
b2927ab419
@@ -365,15 +365,7 @@ public class ParameterBindingDocumentCodec implements CollectibleCodec<Document>
|
||||
reader.readStartArray();
|
||||
List<Object> list = new ArrayList<>();
|
||||
while (reader.readBsonType() != BsonType.END_OF_DOCUMENT) {
|
||||
|
||||
// Spring Data Customization START
|
||||
Object listValue = readValue(reader, decoderContext);
|
||||
if (listValue instanceof Collection) {
|
||||
list.addAll((Collection) listValue);
|
||||
break;
|
||||
}
|
||||
list.add(listValue);
|
||||
// Spring Data Customization END
|
||||
list.add(readValue(reader, decoderContext));
|
||||
}
|
||||
reader.readEndArray();
|
||||
return list;
|
||||
|
||||
@@ -374,6 +374,15 @@ class ParameterBindingJsonReaderUnitTests {
|
||||
.isEqualTo(Document.parse("{ $and: [{'fieldA': {$in: [/ABC.*/, /CDE.*F/]}}, {'fieldB': {$ne: null}}]}"));
|
||||
}
|
||||
|
||||
@Test // DATAMONGO-2633
|
||||
void shouldParseNestedArrays() {
|
||||
|
||||
Document target = parse("{ 'stores.location' : { $geoWithin: { $centerSphere: [ [ ?0, 48.799029 ] , ?1 ] } } }",
|
||||
1.948516D, 0.004D);
|
||||
assertThat(target).isEqualTo(Document
|
||||
.parse("{ 'stores.location' : { $geoWithin: { $centerSphere: [ [ 1.948516, 48.799029 ] , 0.004 ] } } }"));
|
||||
}
|
||||
|
||||
private static Document parse(String json, Object... args) {
|
||||
|
||||
ParameterBindingJsonReader reader = new ParameterBindingJsonReader(json, args);
|
||||
|
||||
Reference in New Issue
Block a user