DATACMNS-1443 - Fixed Querydsl web data binding for blank strings.
We now use StringUtils.hasLength(…) in the check whether to drop request elements from binding instead of ….hasText(…) as the latter drops blank strings so that's impossible to search for properties that contain a blank.
This commit is contained in:
@@ -226,6 +226,6 @@ public class QuerydslPredicateBuilder {
|
||||
* @return
|
||||
*/
|
||||
private static boolean isSingleElementCollectionWithoutText(List<String> source) {
|
||||
return source.size() == 1 && !StringUtils.hasText(source.get(0));
|
||||
return source.size() == 1 && !StringUtils.hasLength(source.get(0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,4 +218,21 @@ public class QuerydslPredicateBuilderUnitTests {
|
||||
|
||||
assertThat(predicate, is((Predicate) $.user.as(QSpecialUser.class).specialProperty.contains("VALUE")));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1443
|
||||
public void doesNotDropValuesContainingABlank() {
|
||||
|
||||
values.add("firstname", " ");
|
||||
|
||||
assertThat(builder.getPredicate(USER_TYPE, values, DEFAULT_BINDINGS), //
|
||||
is((Predicate) QUser.user.firstname.eq(" ")));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1443
|
||||
public void dropsValuesContainingAnEmptyString() {
|
||||
|
||||
values.add("firstname", "");
|
||||
|
||||
assertThat(builder.getPredicate(USER_TYPE, values, DEFAULT_BINDINGS), is(nullValue()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user