Skip to content

Deep Filter Paging issue #377

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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Smtih opened this issue May 9, 2025 · 0 comments · May be fixed by #378
Open

Deep Filter Paging issue #377

Smtih opened this issue May 9, 2025 · 0 comments · May be fixed by #378
Labels
bug Something isn't working

Comments

@Smtih
Copy link

Smtih commented May 9, 2025

Describe the bug
When using deep filters it is possible to break pagination such that you get hasNextPage returning false when there are more rows.

This seems to stem from the sql producing duplicate rows when doing left joins and thinking it's hit the end of the list.

My team noticed that there's some code that seems to look for oneToMany/manyToMany relationships and switch to a skip-take stratergy, however it only looks for this type of relationship in the first layer of filters. I believe we need to look for these relationships at any depth of filter for this behaviour to work properly.

Here's a minimal reproduction of the issue:
https://github.com/Smtih/nestjs-query-pagination-bug/blob/master/test/paging-bug.e2e-spec.ts
(Please have postgres running using docker-compose if trying to reproduce)

The gist of the setup is:

TodoItems have a one-many relation with subtasks
TodoItems have a one-many relation with tags

if we query a paginated list of subtasks, and filter on a condition on tags (via todos) we will hit this bug.

I think we are close to having a PR we can submit to fix the issue that I'll also raise soon.

@Smtih Smtih added the bug Something isn't working label May 9, 2025
@Smtih Smtih linked a pull request May 9, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant