Search code examples
spring-data

Why does Spring Data's Sort.descending() reset ignoreCase?


Sort.descending() javadoc states

"Returns a new Sort with the current setup but descending order direction."

Why does this test fail on the second assert? I would assume (and would like) Sort.descending() to keep ignoreCase as it is (true), but in practice it changes ignoreCase to false?

    @Test
    public void descendingSortShouldRetainCaseInsensitive() {
        var sort = Sort.by(Sort.Order.by("memberName").ignoreCase());
        assertTrue(sort.iterator().next().isIgnoreCase()); // 1 OK
        var sortDesc = sort.descending();
        assertTrue(sortDesc.iterator().next().isIgnoreCase()); // 2 fails
    }

Solution

  • It seems this was a bug, and has now been fixed: https://github.com/spring-projects/spring-data-commons/issues/2585