DATAMONGO-2523 - Fix Json binding of SpEL expressions in arrays.

The closing bracket must not have a leading whitespace.

Original pull request: #859.
This commit is contained in:
Christoph Strobl
2020-04-21 10:08:59 +02:00
committed by Mark Paluch
parent b57e571033
commit 32f3e60c9f
2 changed files with 9 additions and 1 deletions

View File

@@ -231,7 +231,7 @@ class JsonScanner {
parenthesisCount--;
if (parenthesisCount == 0) {
buffer.read();
c = buffer.read();
break;
}
}

View File

@@ -256,6 +256,14 @@ class ParameterBindingJsonReaderUnitTests {
.isEqualTo(new Document("name", new Document("$in", Collections.singletonList("dalinar,kohlin"))));
}
@Test // DATAMONGO-2523
void bindSpelExpressionInArrayCorrectly/* closing bracket must not have leading whitespace! */() {
Document target = parse("{ $and : [?#{ [0] == null ? { '$where' : 'true' } : { 'v1' : { '$in' : {[0]} } } }]}", 1);
assertThat(target).isEqualTo(Document.parse("{\"$and\": [{\"v1\": {\"$in\": [1]}}]}"));
}
private static Document parse(String json, Object... args) {
ParameterBindingJsonReader reader = new ParameterBindingJsonReader(json, args);