Align OffsetScrolling to zero-based indexes.

Closes #1764
This commit is contained in:
Mark Paluch
2024-04-10 15:56:28 +02:00
parent ad8ca20438
commit ae272e2a1e
4 changed files with 13 additions and 6 deletions

View File

@@ -409,7 +409,11 @@ public class SimpleR2dbcRepository<T, ID> implements R2dbcRepository<T, ID> {
int limit = getLimit();
return createQuery(q -> {
Query queryToUse = q.offset(osp.getOffset());
Query queryToUse = q;
if (!osp.isInitial()) {
queryToUse = queryToUse.offset(osp.getOffset() + 1);
}
if (limit > 0) {
queryToUse = queryToUse.limit(limit + 1);
@@ -419,8 +423,7 @@ public class SimpleR2dbcRepository<T, ID> implements R2dbcRepository<T, ID> {
}).all() //
.collectList() //
.map(content -> {
return ScrollDelegate.createWindow(content, limit,
OffsetScrollPosition.positionFunction(osp.getOffset()));
return ScrollDelegate.createWindow(content, limit, osp.positionFunction());
});
}