Skip to content

Default fetch cursor value function fails when base schema has the same field has the binding's #168

@tanguilp

Description

@tanguilp

I have a cursor with 2 fields, one being a preload, something like: [{:author, :name}, :name] (let's say the base schema is :post).

I think the default fetch cursor value erroneously tries to fetch first the field on the base schema: https://github.com/duffelhq/paginator/blob/main/lib/paginator.ex#L243

As a result, if the base schema and the preloaded schema have the same field, then the wrong field from the base schema is used.

In the example above, that would result in the cursor having twice the post's name:

%{:id => 92575, :name => "Post's name", {:author, :name} => "Post's name"}

instead of

%{:id => 92575, :name => "Post's name", {:author, :name} => "Author's name"}

If I've not misunderstood how this library works, I'm ready to provide with a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions