Skip to content

Commit

Permalink
Apply UPPER function to all columns when enabling ignoreCase.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mp911de committed Jan 7, 2021
1 parent 21fcde4 commit 908f17b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ private Condition createCondition(Column column, @Nullable Object mappedValue, C
}

Expression columnExpression = column;
if (ignoreCase && String.class == valueType) {
if (ignoreCase) {
columnExpression = Functions.upper(column);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,19 @@ public void shouldMapSimpleCriteria() {
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() {

Expand Down

0 comments on commit 908f17b

Please sign in to comment.