Fix $or / $nor keyword mapping in query mapper.
This commit fixes an issue with the pattern used for detecting $or / $nor which also matched other keywords like $floor. Closes: #3635 Original pull request: #3637.
This commit is contained in:
committed by
Mark Paluch
parent
5cf801ff8e
commit
5d8f3d5c8b
@@ -721,7 +721,6 @@ public class QueryMapper {
|
||||
*/
|
||||
static class Keyword {
|
||||
|
||||
private static final String N_OR_PATTERN = "\\$.*or";
|
||||
private static final Set<String> NON_DBREF_CONVERTING_KEYWORDS = new HashSet<>(
|
||||
Arrays.asList("$", "$size", "$slice", "$gt", "$lt"));
|
||||
|
||||
@@ -752,7 +751,7 @@ public class QueryMapper {
|
||||
}
|
||||
|
||||
public boolean isOrOrNor() {
|
||||
return key.matches(N_OR_PATTERN);
|
||||
return key.equalsIgnoreCase("$or") || key.equalsIgnoreCase("$nor");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1093,6 +1093,14 @@ public class QueryMapperUnitTests {
|
||||
assertThat(document).isEqualTo(new org.bson.Document("stringAsOid", null));
|
||||
}
|
||||
|
||||
@Test // GH-3635
|
||||
void $floorKeywordDoesNotMatch$or$norPattern() {
|
||||
|
||||
Query query = new BasicQuery(" { $expr: { $gt: [ \"$spent\" , { $floor : \"$budget\" } ] } }");
|
||||
assertThatNoException()
|
||||
.isThrownBy(() -> mapper.getMappedObject(query.getQueryObject(), context.getPersistentEntity(Foo.class)));
|
||||
}
|
||||
|
||||
class WithDeepArrayNesting {
|
||||
|
||||
List<WithNestedArray> level0;
|
||||
|
||||
Reference in New Issue
Block a user