Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Bug: API V2 - when Page Size > Total Records returned, API response contains incorrect page size and isLastpage values #7368

Closed
1 task done
woodmin opened this issue Jan 4, 2024 · 2 comments
Assignees
Labels
Status: Reproducible Able to reproduce the issue based on the reporters' guideline.

Comments

@woodmin
Copy link

woodmin commented Jan 4, 2024

Please confirm if bug report does NOT exists already ?

  • I confirm there is no existing issue for this

Steps to reproduce ?

Create 4 records.
Set offset to 2.
Set Page Size to 50.
Returns page: 1.04 decimal (!?) and incorrect
Returns isLastPage: false incorrect

Desired Behavior

Should return page: 1 integer
Should return isLastPage: true

Project Details

Node: v18.18.2
Arch: x64
Platform: linux
Docker: true
RootDB: pg
PackageVersion: 0.203.2
Database version : 16.1

Attachments

image

@dstala dstala added this to the vNext milestone Jan 5, 2024
@dstala
Copy link
Member

dstala commented Jan 5, 2024

isLastPage always returns false if offset is set. fix for page to be discussed

@dstala dstala added the Status: Reproducible Able to reproduce the issue based on the reporters' guideline. label Jan 5, 2024
@woodmin
Copy link
Author

woodmin commented Jan 5, 2024

  1. I think there is some misunderstanding regarding isLastPage - it is not always returning false if offset is set. It only returns false if the page is not the last, and normally it does return true on the last page. This is the whole point of isLastPage and we are using it to stop turning pages at the end of results. Offset is always used (offset = n x limit) for every page except the first one. Please see screenshot below.
    So to summarize: in normal circumstances isLastPage works as it should, and returns true for the last page with the last page offset value.
    image

  2. The problem reported here is that it does not work as expected for the last page ONLY WHEN a) when Page Size (limit) > Total Records (totalRows) returned and b) offset is applied. This does not happen in regular pagination situations, but when some offset is applied from the get-go. We encountered it when we wanted to retrieve the last record in the table. So having n records in the table we applied n-1 offset to retrieve that last record. However, since our Page Size (limit) was > Total Records (totalRows), isLastPage incorrectly returned false although it should have worked wirth any Page Size (limit) and returned true whenever it contained the last record form the list. Sinced it returns false for isLastPage for the last record in the list, it incorrectly implies that pagination mechanism should increase offset and continue paginating, although no more records exist.

Hope it clarifies it.

@dstala dstala closed this as completed Jan 11, 2024
@dstala dstala removed this from the vNext milestone Jan 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Reproducible Able to reproduce the issue based on the reporters' guideline.
Projects
None yet
Development

No branches or pull requests

3 participants