From 1169c4b30850104d34ab48400925a0fbee07ef90 Mon Sep 17 00:00:00 2001 From: None of your business Date: Sat, 28 Nov 2026 16:33:06 +0000 Subject: [PATCH] Allow {:late, id_tuple} calls to that write directly into the ownership pool - the db_connection library needs to then be able to figure out when a :late binding is set --- lib/ecto/adapters/sql/sandbox.ex | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/ecto/adapters/sql/sandbox.ex b/lib/ecto/adapters/sql/sandbox.ex index 5fb99852..7ec1bb08 100644 --- a/lib/ecto/adapters/sql/sandbox.ex +++ b/lib/ecto/adapters/sql/sandbox.ex @@ -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)