patch
patch copied to clipboard
Using `Ecto.Changeset.cast/4` within a patch causes an error
If you try to call Ecto.Changeset.cast inside of a patched function, it raises an ** (EXIT) process attempted to call itself
Minimum reproduction:
defmodule ToBePatched do
use Ecto.Schema
embedded_schema do
field :foo, :string
end
def changeset(arg1, arg2) do
Ecto.Changeset.cast(arg1, arg2, [:foo])
end
end
defmodule ToBePatchedTest do
use ExUnit.Case
use Patch
test "this shouldn't fail" do
patch(ToBePatched, :changeset, fn arg1, arg2 ->
Ecto.Changeset.cast(arg1, arg2, [:foo})
end)
ToBePatched.changeset(%ToBePatched{}, %{})
end
end