Skip to content

Commit

Permalink
more consistent implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
aparkerdavid committed Jan 14, 2025
1 parent fe8375d commit 9c497d9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/scrivener/paginater/ecto/query.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ defimpl Scrivener.Paginater, for: Ecto.Query do
options
|> Keyword.put_new(:caller, caller)
|> Keyword.get_lazy(:total_entries, fn ->
aggregate(%{query | select: nil}, repo, options)
aggregate(query, repo, options)
end)

total_pages = total_pages(total_entries, page_size)
Expand Down Expand Up @@ -73,7 +73,9 @@ defimpl Scrivener.Paginater, for: Ecto.Query do
end

defp aggregate(query, repo, options) do
repo.aggregate(query, :count, options)
query
|> exclude(:select)
|> repo.aggregate(:count, options)
end

defp total_pages(0, _), do: 1
Expand Down

0 comments on commit 9c497d9

Please sign in to comment.