Affects Version/s: None
Fix Version/s: None
I'd like to open a discussion about simplifying the use of Pageable API's using the Pageable (and PageableHandlerMethodArgumentResolver).
Currently the PageableHandlerMethodArgumentResolver will only provide a Pageable#isPaged Object when either the page or pageSize Parameter are set. But if a sort Parameter was specified without the use of those Parameter, you will end up with a Pageable.unpaged() ommitting the sort.
I know you can also inject a Sort into the Controller, which works fine. But then you'd need to decide whether you use the Pageable or Sort to pass on (see below).
So I would propose something like the following:
- Support Sort in Unpaged, like isPaged and isSorted
- Support the parsing of Sort in PageableHandlerMethodArgumentResolver when there is no page info (page, size) but a sort
- Change all usages of Pageable#isPaged to account for Pageable#isSorted, like here https://github.com/spring-projects/spring-data-jpa/blob/476baa480912f5e239905da0172fae1faba1d902/src/main/java/org/springframework/data/jpa/repository/support/SimpleJpaRepository.java#L352
If this could be implemented, we could write a simple Controller and account for all possible combinations of page, size and sort missing or provided. This would be the usage example:
This is the current example you'd have to use.