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:
@@ -480,7 +480,7 @@ public class QueryMapper {
|
||||
}
|
||||
|
||||
Expression columnExpression = column;
|
||||
if (ignoreCase && String.class == valueType) {
|
||||
if (ignoreCase) {
|
||||
columnExpression = Functions.upper(column);
|
||||
}
|
||||
|
||||
|
||||
@@ -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() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user