Description
Hi,
a few years ago, the initial feature request was created to allow setting the null handling via the 'sort' query parameters.
In the mean time, this was picked up by jakartaee/persistence (jakartaee/persistence#76) and, as far as I can tell, there is progress made in getting this into spring-data-jpa for 3.4.0.
Following addition to the @SortDefault
annotation could be made:
@SortDefault(
value = "property",
direction = Sort.Direction.DESC,
nullHandling = Sort.NullHandling.NULLS_LAST
)
Following addition to the sort query param could be made:
?sort=(propertyName)+(,ASC|,DESC)?(,ignorecase)?(,nullsnative|,nullsfirst|,nullslast)?
The null handling would be optional, and work in any combination with the remaining, optional parameters. A few, valid examples would be:
?sort=property1
?sort=property1,property2,nullsfirst
?sort=property1,asc,nullslast
?sort=property1,property2,desc,ignorecase,nullsnative
As the SortHandlerMethodArgumentResolverSupport is part of spring-data-commons, I opted to create the issue here again to have an issue number in this project, hope this was the right approach.
Edit: A draft PR implementing the suggestion can be found here: #3153. Happy to hear any suggestions you might have!
Activity
Add null handling to sort query parameters
Add null handling to sort query parameters
Add null handling to sort query parameters
dmarsh26 commentedon Jan 31, 2025
Any news on this being completed and closed?