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:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user