patch icon indicating copy to clipboard operation
patch copied to clipboard

Using `Ecto.Changeset.cast/4` within a patch causes an error

Open Th3-M4jor opened this issue 2 years ago • 1 comments

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

Th3-M4jor avatar Jul 12 '23 19:07 Th3-M4jor

@Th3-M4jor can you see if this is still an issue with 0.14.0

ihumanable avatar Oct 15 '24 18:10 ihumanable

Confirmed, its working fine now in 0.14

Th3-M4jor avatar Oct 20 '24 15:10 Th3-M4jor