Skip to content

Query.pageRequest(…) does not apply the page size when QueryOptions are already set #1681

Closed

Description

@chuuminggg

Query.pageRequest(Pageable) no longer applies the page size when the Query already has QueryOptions.

Since 4d12b02 (#1636), the page size is set only inside the orElseGet(…) fallback:

QueryOptions queryOptions = this.queryOptions.map(QueryOptions::mutate).orElseGet(() -> {

	QueryOptions.QueryOptionsBuilder builder = QueryOptions.builder();
	if (pageable.isPaged()) {
		builder.pageSize(pageable.getPageSize());
	}
	return builder;
}).build();

Before that change, .pageSize(pageable.getPageSize()) was applied to both the mutated and the new builder.

Reproducer

Query query = Query.empty()
		.queryOptions(QueryOptions.builder().consistencyLevel(DefaultConsistencyLevel.QUORUM).build())
		.pageRequest(PageRequest.of(0, 10));

// QueryOptions.pageSize is null, expected 10

template.slice(query, …) then runs with the driver's default page size (5000) instead of 10, so the returned Slice contains more elements than requested. A follow-up query.pageRequest(slice.nextPageable()) with a different page size is also ignored.

pageRequest(…) already returns early for unpaged requests, so the page size can be applied unconditionally again.

Affected versions

main, 5.1.x, 5.0.x and 4.5.x (the #1636 fix was backported).

I'm happy to submit a pull request.

Activity

  1. self-assigned this
    on Oct 16, 2026
  2. added 2 commits that reference this issue on Oct 16, 2026
    8848845
    6f67f70
  3. added a commit that references this issue on Oct 17, 2026
    c954525
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions