spring-projects / spring-projects/spring-data-rest
default sort doesn't work [DATAREST-82]
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 958
- Forks
- 568
- PR merge metrics
- No merged PRs in 30d
Description
Alexei Guevara opened DATAREST-82 and commented
When creating a repository that extends PagingAndSortingRepository the method PagingAndSortingRepository.findAll(Sort sort) is not recognized as a sort method when the user hits the url ".../entities?sort=name&name.dir=asc
The root cause of the problem is in the class RepositoryMethodInvoker.
Line 50 of RepositoryMethodInvoker reads as:
boolean someMethod = (null != paramType && Iterable.class.isAssignableFrom(paramType));
Which causes the method PagingAndSortingRepository.findAll(Sort sort) to be categorized as "someMethod" because Sort implements Iterable.
As a result the code in line 67
findAllSorted = repoMethod;
is never triggered because the code in line 65 takes precedence
findSome = repoMethod;
Affects: 1.1.0.M1
Referenced from: commits https://github.com/spring-projects/spring-data-rest/commit/462adb5a79ddea57db0e56d98380e7c8f68c1c58, https://github.com/spring-projects/spring-data-rest/commit/f60219480ff4caf8d9072e47cf2c25b01ba8e6e9
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in RepositoryMethodInvoker, focusing on the parameter classification around lines 50, 65, and 67. Reproduce the PagingAndSortingRepository.findAll(Sort sort) request using the documented URL shape, then verify that the sort method is recognized and the default sort behavior works.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100