spring-projects / spring-projects/spring-data-jpa
Remove bogus logic in count query [DATAJPA-1635]
@schauder is already working on this.
Since Dec 30, 2020.
- Dominant language
- Java
- Stars
- 3.3k
- Forks
- 1.6k
- PR merge metrics
- No merged PRs in 30d
Description
Jens Schauder opened DATAJPA-1635 and commented
PagedExecution.count contains the following logic:
List<?> totals = repositoryQuery.createCountQuery(accessor).getResultList();
return (totals.size() == 1 ? CONVERSION_SERVICE.convert(totals.get(0), Long.class) : totals.size());
Which doesn't make sense since a count query should always only return a single result and if it doesn't just counting the results won't yield a meaningful result.
Turns out this exists only due to a bug in some unit tests that use the mocked original query for the count query
Referenced from: pull request https://github.com/spring-projects/spring-data-jpa/pull/400, and commits https://github.com/spring-projects/spring-data-jpa/commit/b9e9c6b0a1262f1a973383430cf9574d058efd92, https://github.com/spring-projects/spring-data-jpa/commit/4dea8eb25702c88e631c6c5b0846f1edab26d9a6
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.
Assessment
This issue has not been assessed yet.