Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Allow specifying null handling for 'sort' query params as well as setting a default #3152

Open
Assignees
@pheyken

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!

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      AltStyle によって変換されたページ (->オリジナル) /