Skip to content

Commit

Permalink
Don't pass prefix when nil
Browse files Browse the repository at this point in the history
  • Loading branch information
drewolson committed Nov 23, 2020
1 parent 5405802 commit 8c64502
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions lib/scrivener/paginater/ecto/query.ex
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ defimpl Scrivener.Paginater, for: Ecto.Query do
query
|> offset(^offset)
|> limit(^page_size)
|> repo.all(caller: caller, prefix: prefix)
|> all(repo, caller, prefix)
end

defp total_entries(query, repo, caller, options) do
Expand All @@ -53,7 +53,7 @@ defimpl Scrivener.Paginater, for: Ecto.Query do
|> exclude(:preload)
|> exclude(:order_by)
|> aggregate()
|> repo.one(caller: caller, prefix: prefix)
|> one(repo, caller, prefix)

total_entries || 0
end
Expand Down Expand Up @@ -99,4 +99,20 @@ defimpl Scrivener.Paginater, for: Ecto.Query do
defp total_pages(total_entries, page_size) do
(total_entries / page_size) |> Float.ceil() |> round
end

defp all(query, repo, caller, nil) do
repo.all(query, caller: caller)
end

defp all(query, repo, caller, prefix) do
repo.all(query, caller: caller, prefix: prefix)
end

defp one(query, repo, caller, nil) do
repo.one(query, caller: caller)
end

defp one(query, repo, caller, prefix) do
repo.one(query, caller: caller, prefix: prefix)
end
end

0 comments on commit 8c64502

Please sign in to comment.