Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/ecto/adapter/queryable.ex
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,14 @@ defmodule Ecto.Adapter.Queryable do
def prepare_query(operation, repo_name_or_pid, queryable, opts \\ []) do
%{adapter: adapter, cache: cache} = Ecto.Repo.Registry.lookup(repo_name_or_pid)

counter = Keyword.get(opts, :counter, 0)
query_cache? = Keyword.get(opts, :query_cache, true)

{_meta, prepared, _cast_params, dump_params} =
queryable
|> Ecto.Queryable.to_query()
|> Ecto.Query.Planner.ensure_select(operation == :all)
|> Ecto.Query.Planner.query(operation, cache, adapter, 0, query_cache?)
|> Ecto.Query.Planner.query(operation, cache, adapter, counter, query_cache?)

{prepared, dump_params}
end
Expand Down
2 changes: 1 addition & 1 deletion lib/ecto/query/planner.ex
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ defmodule Ecto.Query.Planner do
def query(query, operation, cache, adapter, counter, query_cache?) do
{query, params, key} = plan(query, operation, adapter)
{cast_params, dump_params} = Enum.unzip(params)
key = if query_cache?, do: key, else: :nocache
key = if query_cache?, do: {key, counter}, else: :nocache
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zachdaniel I thought it would be better to always add the counter, to reduce the number of branches, but it seems that either using a list is wrong or we are messing with the key in an incompatible way. Can you please take a deeper look?

query_with_cache(key, query, operation, cache, adapter, counter, cast_params, dump_params)
end

Expand Down
Loading