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
12 changes: 10 additions & 2 deletions lib/ecto/adapters/sql/sandbox.ex
Original file line number Diff line number Diff line change
Expand Up @@ -599,9 +599,17 @@ defmodule Ecto.Adapters.SQL.Sandbox do
owner or already allowed, it returns `{:already, :owner | :allowed}`. If `parent` has not
checked out a connection from the repo, it returns `:not_found`.
"""
@spec allow(Ecto.Repo.t() | pid(), pid(), term()) ::
@spec allow(Ecto.Repo.t() | pid(), pid(), {:late, {:local | :global, term()}} | term()) ::
:ok | {:already, :owner | :allowed} | :not_found
def allow(repo, parent, allow, opts \\ []) when is_atom(repo) or is_pid(repo) do
def allow(repo, parent, allow, opts \\ [])

def allow(repo, parent, {:late, _} = late, opts) when is_atom(repo) or is_pid(repo) do
%{pid: pool, opts: meta_opts} = lookup_meta!(repo)
opts = Keyword.merge(meta_opts, opts)
DBConnection.Ownership.ownership_allow(pool, parent, late, opts)
end

def allow(repo, parent, allow, opts) when is_atom(repo) or is_pid(repo) do
case GenServer.whereis(allow) do
pid when is_pid(pid) ->
%{pid: pool, opts: meta_opts} = lookup_meta!(repo)
Expand Down