Skip to content

Commit

Permalink
Apply filters before modifying query
Browse files Browse the repository at this point in the history
  • Loading branch information
michallepicki committed May 27, 2023
1 parent f914c40 commit 718c8d4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/flop.ex
Original file line number Diff line number Diff line change
Expand Up @@ -772,8 +772,14 @@ defmodule Flop do
if count = opts[:count] do
count
else
q = opts[:count_query] || count_query(q)
apply_on_repo(:aggregate, "count", [filter(q, flop, opts), :count], opts)
q =
if opts[:count_query] do
filter(opts[:count_query], flop, opts)
else
count_query(filter(q, flop, opts))
end

apply_on_repo(:aggregate, "count", [q, :count], opts)
end
end

Expand Down

0 comments on commit 718c8d4

Please sign in to comment.