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:
Oliver Drotbohm
2018-12-10 17:26:14 +01:00
parent c6a784c2fe
commit d75ab305c8
2 changed files with 18 additions and 1 deletions

View File

@@ -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));
}
}

View File

@@ -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()));
}
}