Apply UPPER function to all columns when enabling ignoreCase.

We now apply the UPPER function regardless of whether we could resolve the criteria property to a column. Previously, we required a resolved property of a String type which prevented non-mapped properties from case-insensitive queries.

Closes #518
This commit is contained in:
Mark Paluch
2021-01-07 15:35:00 +01:00
parent 2b4bc0d140
commit 6e7e03963d
2 changed files with 14 additions and 1 deletions

View File

@@ -480,7 +480,7 @@ public class QueryMapper {
}
Expression columnExpression = column;
if (ignoreCase && String.class == valueType) {
if (ignoreCase) {
columnExpression = Functions.upper(column);
}

View File

@@ -155,6 +155,19 @@ public class QueryMapperUnitTests {
verify(bindTarget).bind(0, "foo");
}
@Test // gh-518
public void shouldMapSimpleCriteriaWithIgnoreCase() {
Criteria criteria = Criteria.where("some_col").is("foo").ignoreCase(true);
BoundCondition bindings = map(criteria);
assertThat(bindings.getCondition()).hasToString("UPPER(person.some_col) = UPPER(?[$1])");
bindings.getBindings().apply(bindTarget);
verify(bindTarget).bind(0, "foo");
}
@Test // gh-300
public void shouldMapSimpleCriteriaWithoutEntity() {