spring-projects / spring-data-commons

Spring Data Commons. Interfaces and code shared between the various datastore specific implementations.
https://spring.io/projects/spring-data
Apache License 2.0
785 stars 677 forks source link

Latest Refactor on QueryDsl argument resolution breaks it when pagination and other parameters are supplied to the request [DATACMNS-1559] #1988

Open spring-projects-issues opened 5 years ago

spring-projects-issues commented 5 years ago

Marc opened DATACMNS-1559 and commented

QuerydslPredicateBuilder.getPredicate() was refactored 2 or 3 commits ago, changing the logic in a way that now when incoming params multimap is empty, a new empty BooleanBuilder() instance is returned. 

But when params multimap comes populated and it is iterated without any successful binding , instead of returning the coherent empty BooleanBuilder() instance, its getValue(), which equals null, is returned instead.

This means that behavior is inconsistent for when no relevant associations are found, the result is different depending on whether the multimap  is empty or contanis footobeignored.

 

This effectively affects current version of spring-data-rest's QuerydslAwareRootResourceInformationHandlerMethodArgumentResolver, since it was also refactored to instantiate QuerydslRepositoryInvokerAdapter only on the event of non null preficates, otherwise it returns the default invoker which is the UnwrappingRepository one that ignores querydsl predicates.

 

This means that  current released library resolves a QueryDsl aware invoker only if you don't provide pagination or other kinds of params 


Affects: 2.1.9 (Lovelace SR9)

Reference URL: https://github.com/spring-projects/spring-data-commons/blob/master/src/main/java/org/springframework/data/querydsl/binding/QuerydslPredicateBuilder.java

1 votes, 3 watchers

spring-projects-issues commented 5 years ago

Mark Paluch commented

Thanks for report. Can you provide a test/reproducer for the issue?