From 9c497d98f86d59780b7d82eac2506502a03c6ce6 Mon Sep 17 00:00:00 2001 From: Parker Rueve Date: Tue, 14 Jan 2025 14:34:36 -0500 Subject: [PATCH] more consistent implementation --- lib/scrivener/paginater/ecto/query.ex | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/scrivener/paginater/ecto/query.ex b/lib/scrivener/paginater/ecto/query.ex index 465703e..31efa45 100644 --- a/lib/scrivener/paginater/ecto/query.ex +++ b/lib/scrivener/paginater/ecto/query.ex @@ -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) @@ -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