Skip to content

Deep Filter Paging issue #377

@Smtih

Description

@Smtih

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions