Skip to content

Commit 908f17b

Browse files
committed
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
1 parent 21fcde4 commit 908f17b

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/main/java/org/springframework/data/r2dbc/query/QueryMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ private Condition createCondition(Column column, @Nullable Object mappedValue, C
457457
}
458458

459459
Expression columnExpression = column;
460-
if (ignoreCase && String.class == valueType) {
460+
if (ignoreCase) {
461461
columnExpression = Functions.upper(column);
462462
}
463463

src/test/java/org/springframework/data/r2dbc/query/QueryMapperUnitTests.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,19 @@ public void shouldMapSimpleCriteria() {
155155
verify(bindTarget).bind(0, "foo");
156156
}
157157

158+
@Test // gh-518
159+
public void shouldMapSimpleCriteriaWithIgnoreCase() {
160+
161+
Criteria criteria = Criteria.where("some_col").is("foo").ignoreCase(true);
162+
163+
BoundCondition bindings = map(criteria);
164+
165+
assertThat(bindings.getCondition()).hasToString("UPPER(person.some_col) = UPPER(?[$1])");
166+
167+
bindings.getBindings().apply(bindTarget);
168+
verify(bindTarget).bind(0, "foo");
169+
}
170+
158171
@Test // gh-300
159172
public void shouldMapSimpleCriteriaWithoutEntity() {
160173

0 commit comments

Comments
 (0)