Skip to content

Commit ef5d291

Browse files
committed
Allow explicitly passing a dynamic repo to Ecto.Adapters.SQL.Sandbox.checkout/1
1 parent e223a37 commit ef5d291

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/ecto/adapters/sql/sandbox.ex

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -646,8 +646,11 @@ defmodule Ecto.Adapters.SQL.Sandbox do
646646
meta
647647
end
648648

649-
defp find_repo(repo) when is_atom(repo), do: repo.get_dynamic_repo()
650-
defp find_repo(repo), do: repo
649+
defp find_repo(repo) do
650+
if is_atom(repo) and Code.ensure_loaded?(repo),
651+
do: repo.get_dynamic_repo(),
652+
else: repo
653+
end
651654

652655
defp post_checkout(conn_mod, conn_state, opts) do
653656
case conn_mod.handle_begin([mode: :transaction] ++ opts, conn_state) do

0 commit comments

Comments
 (0)