Skip to content
Open
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
18 changes: 12 additions & 6 deletions lib/ecto/adapters/sql.ex
Original file line number Diff line number Diff line change
Expand Up @@ -492,10 +492,16 @@ defmodule Ecto.Adapters.SQL do
"""

@doc @to_sql_doc
@spec to_sql(:all | :update_all | :delete_all, Ecto.Repo.t(), Ecto.Queryable.t()) ::
@spec to_sql(:all | :update_all | :delete_all, Ecto.Repo.t(), Ecto.Queryable.t(), Keyword.t()) ::
{String.t(), query_params}
def to_sql(kind, repo, queryable) do
case Ecto.Adapter.Queryable.prepare_query(kind, repo, queryable) do
def to_sql(kind, repo, queryable, opts \\ []) do
prepare_opts =
case Keyword.fetch(opts, :counter) do
{:ok, counter} -> [counter: counter]
:error -> []
end

case Ecto.Adapter.Queryable.prepare_query(kind, repo, queryable, prepare_opts) do
{{:cached, _update, _reset, {_id, cached}}, params} ->
{String.Chars.to_string(cached), params}

Expand Down Expand Up @@ -825,10 +831,10 @@ defmodule Ecto.Adapters.SQL do
end

@doc unquote(to_sql_doc)
@spec to_sql(:all | :update_all | :delete_all, Ecto.Queryable.t()) ::
@spec to_sql(:all | :update_all | :delete_all, Ecto.Queryable.t(), Keyword.t()) ::
{String.t(), Ecto.Adapters.SQL.query_params()}
def to_sql(operation, queryable) do
Ecto.Adapters.SQL.to_sql(operation, get_dynamic_repo(), queryable)
def to_sql(operation, queryable, opts \\ []) do
Ecto.Adapters.SQL.to_sql(operation, get_dynamic_repo(), queryable, opts)
end

@doc unquote(explain_doc)
Expand Down
Loading