Elixir version
any
Database and Version
any
Ecto Versions
3.14.1
Database Adapter and Versions (postgrex, myxql, etc)
any
Current behavior
Using the list form of the :autogenerate field option with a parameterized or composite type compiles successfully but crashes on the first Repo.insert/2.
This appears to be a regression introduced by e6da70d
Repro:
defmodule MyParameterizedType do
use Ecto.ParameterizedType
def init(opts), do: opts
def type(_params), do: :string
def cast(value, _params), do: {:ok, value}
def load(value, _loader, _params), do: {:ok, value}
def dump(value, _dumper, _params), do: {:ok, value}
def autogenerate(opts), do: Keyword.fetch!(opts, :value)
end
defmodule Example do
use Ecto.Schema
schema "examples" do
field :value, MyParameterizedType,
autogenerate: [value: "generated"]
end
end
Repo.insert!(%Example{})
Result:
** (ArgumentError) you attempted to apply a function on
{:parameterized, {MyParameterizedType, ...}}.
Modules (the first argument of apply) must always be an atom
The same problem affects composite types
field :values, {:array, MyType},
autogenerate: [value: ["generated"]]
Expected behavior
No crash
Elixir version
any
Database and Version
any
Ecto Versions
3.14.1
Database Adapter and Versions (postgrex, myxql, etc)
any
Current behavior
Using the list form of the
:autogeneratefield option with a parameterized or composite type compiles successfully but crashes on the first Repo.insert/2.This appears to be a regression introduced by e6da70d
Repro:
Result:
The same problem affects composite types
Expected behavior
No crash