Skip to content

Commit 386f47f

Browse files
committed
chore: accept a counter option in prepare_query/3
1 parent a7f390f commit 386f47f

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

lib/ecto/adapter/queryable.ex

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,20 @@ defmodule Ecto.Adapter.Queryable do
104104
def prepare_query(operation, repo_name_or_pid, queryable, opts \\ []) do
105105
%{adapter: adapter, cache: cache} = Ecto.Repo.Registry.lookup(repo_name_or_pid)
106106

107-
query_cache? = Keyword.get(opts, :query_cache, true)
107+
counter = Keyword.get(opts, :counter, 0)
108+
109+
query_cache? =
110+
if counter != 0 do
111+
false
112+
else
113+
Keyword.get(opts, :query_cache, true)
114+
end
108115

109116
{_meta, prepared, _cast_params, dump_params} =
110117
queryable
111118
|> Ecto.Queryable.to_query()
112119
|> Ecto.Query.Planner.ensure_select(operation == :all)
113-
|> Ecto.Query.Planner.query(operation, cache, adapter, 0, query_cache?)
120+
|> Ecto.Query.Planner.query(operation, cache, adapter, counter, query_cache?)
114121

115122
{prepared, dump_params}
116123
end

0 commit comments

Comments
 (0)