Skip to content

MongoRepository.findAll(Pageable) ignores Sort when using unpaged Pageable #4771

Closed
@Dekay21

Description

@Dekay21

I was trying to call the method findAll(Pageable pageable) on a MongoRepository instance with the following pageable: Pageable.unpaged(sort)
When looking at the data i saw that the sort order was ignored completely.

After digging through the sources I think the issues lies in Query.java

public Query with(Pageable pageable) {

    if (pageable.isUnpaged()) {
        return this; // <--- Here the sort is being ignored
    }

    this.limit = pageable.toLimit();
    this.skip = pageable.getOffset();

    return with(pageable.getSort());
}

As a work around i use PageRequest.of(0, Integer.MAX_VALUE, sort) but would be nice if this could be changed as it's not something you would expect

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions