Support case-insensitive RSQL expressions /target filters (#1137)

* Interpret /parse RSQL expressions case insensitive

Signed-off-by: Stefan Behl <stefan.behl@bosch.io>

* Add unit test verifying that RSQL expressions are case insensitive

Signed-off-by: Stefan Behl <stefan.behl@bosch.io>
This commit is contained in:
Stefan Behl
2021-07-05 18:05:10 +02:00
committed by GitHub
parent 4d5b2b3f71
commit a8f7f50cf9
2 changed files with 9 additions and 2 deletions

View File

@@ -136,7 +136,7 @@ public final class RSQLUtility {
public static <A extends Enum<A> & FieldNameProvider, T> Specification<T> parse(final String rsql,
final Class<A> fieldNameProvider, final VirtualPropertyReplacer virtualPropertyReplacer,
final Database database) {
return new RSQLSpecification<>(rsql.toLowerCase(), fieldNameProvider, virtualPropertyReplacer, database);
return new RSQLSpecification<>(rsql, fieldNameProvider, virtualPropertyReplacer, database);
}
/**
@@ -162,7 +162,7 @@ public final class RSQLUtility {
try {
LOGGER.debug("Parsing rsql string {}", rsql);
final Set<ComparisonOperator> operators = RSQLOperators.defaultOperators();
return new RSQLParser(operators).parse(rsql);
return new RSQLParser(operators).parse(rsql.toLowerCase());
} catch (final IllegalArgumentException e) {
throw new RSQLParameterSyntaxException("rsql filter must not be null", e);
} catch (final RSQLParserException e) {

View File

@@ -142,6 +142,13 @@ public class RSQLUtilityTest {
RSQLUtility.validateRsqlFor(rsql2, TestFieldEnum.class);
RSQLUtility.validateRsqlFor(rsql3, TestFieldEnum.class);
}
@Test
@Description("Verify that RSQL expressions are validated case insensitive")
public void mixedCaseRsqlFieldValidation() {
final String rsqlWithMixedCase = "name==b And name==c aND Name==d OR NAME=iN=y oR nAme=IN=z";
RSQLUtility.validateRsqlFor(rsqlWithMixedCase, TargetFields.class);
}
@Test
public void wrongRsqlSyntaxThrowSyntaxException() {