Skip to content

Sort is not working when declared in Pageable in spring-data-couchbase version 4.3.0 #1304

Closed
@Imritg

Description

@Imritg

Hi,
I recently upgraded to spring-data-couchbase 4.3.0 and sort (which worked in 4.2.5) stoped working.
I did changes in order to make it work.

After checking the differences between both versions, it looks like there is a missing assignment in 4.3.0.

spring-data-couchbase - 4.3.0 (Does not set sort and the returned value is ignored)

public Query with(final Pageable pageable) {
    if (pageable.isUnpaged()) {
        return this;
    } else {
        this.limit = pageable.getPageSize();
        this.skip = pageable.getOffset();
        if (!this.sort.equals(pageable.getSort())) {
            this.sort.and(pageable.getSort());
        }
        return this;
    }
}
 
public Sort and(Sort sort) {
    Assert.notNull(sort, "Sort must not be null!");
    ArrayList<Sort.Order> these = new ArrayList(this.orders);
    Iterator var3 = sort.iterator();
    while(var3.hasNext()) {
        Sort.Order order = (Sort.Order)var3.next();
        these.add(order);
    }
    return by((List)these);
}

spring-data-couchbase - 4.2.5 - working - sort is set

public Query with(final Pageable pageable) {
    if (pageable.isUnpaged()) {
        return this;
    } else {
        this.limit = pageable.getPageSize();
        this.skip = pageable.getOffset();
        return this.with(pageable.getSort());
    }
}
 
public Query with(Sort sort) {
    Assert.notNull(sort, "Sort must not be null!");
    if (sort.isUnsorted()) {
        return this;
    } else {
        this.sort = this.sort.and(sort);
        return this;
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: regressionA regression from a previous release

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions