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

Already on GitHub? Sign in to your account

Query with a fragment seems to return the after and before keys swapped. #169

Open
alvesl opened this issue Aug 10, 2022 · 2 comments
Open

Comments

@alvesl
Copy link

alvesl commented Aug 10, 2022

Example query:

   Model
    |> order_by([o], desc: fragment("date(?)", o.inserted_at))
    |> group_by([o], fragment("date(?)", o.inserted_at))
    |> select([o], %{fragment("date(?)", o.inserted_at) => sum(o.amount)})
    |> Repo.paginate(Keyword.merge(opts, sort_direction: :desc, cursor_fields: [:inserted_at]))

Returns properly and seems to paginate correctly if I pass in the before Key. For some reason the after key returns the same element. Any idea what is going on?

@alvesl
Copy link
Author

alvesl commented Sep 19, 2022

ping

@peaceful-james
Copy link

I think you need a window function to achieve paginating after grouping. See this question on Stackoverflow: https://stackoverflow.com/questions/54329389/postgresql-paginate-by-rows-group

So I do not think this is a bug in the library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants