Unwrap nested collections in default Querydsl binding.

When binding values to collection-like paths, we now unwrap potentially double-wrapped collections as QuerydslPredicateBuilder attempts to convert the binding value to the type of the path.

Our default is a contains binding for single elements.

Closes #2834
This commit is contained in:
Mark Paluch
2023-06-02 10:29:57 +02:00
parent 2937d620ad
commit bfcb2ffeae
3 changed files with 24 additions and 10 deletions

View File

@@ -59,7 +59,16 @@ class QuerydslDefaultBinding implements MultiValueBinding<Path<? extends Object>
BooleanBuilder builder = new BooleanBuilder();
for (Object element : value) {
builder.and(((CollectionPathBase) path).contains(element));
if (element instanceof Collection<?> nestedCollection) {
for (Object nested : nestedCollection) {
builder.and(((CollectionPathBase) path).contains(nested));
}
} else {
builder.and(((CollectionPathBase) path).contains(element));
}
}
return Optional.of(builder.getValue());