fix: Enum types only have storage_type/0 still

This commit is contained in:
Zach Daniel 2023-08-17 17:57:50 -04:00
parent b51dbe49c9
commit 50164049df
2 changed files with 5 additions and 2 deletions

View file

@ -46,7 +46,7 @@ defmodule Ash.Type.Enum do
def values, do: @values
@impl Ash.Type
def storage_type(_), do: :string
def storage_type, do: :string
@impl Ash.Type
def generator(_constraints) do
@ -120,7 +120,7 @@ defmodule Ash.Type.Enum do
:error
end
defoverridable storage_type: 1
defoverridable storage_type: 0
end
end
end

View file

@ -147,6 +147,7 @@ defmodule Ash.Type do
authorize?: boolean | nil
}
@callback storage_type() :: Ecto.Type.t()
@callback storage_type(constraints) :: Ecto.Type.t()
@doc """
Useful for typed data layers (like ash_postgres) to instruct them not to attempt to cast input values.
@ -203,6 +204,7 @@ defmodule Ash.Type do
{:ok, list(term)} | {:error, Ash.Error.t()}
@optional_callbacks [
storage_type: 0,
cast_stored_array: 2,
generator: 1,
cast_input_array: 2,
@ -1111,6 +1113,7 @@ defmodule Ash.Type do
raise "Must only define storage_type/0 or storage_type/1 but not both"
Module.defines?(__MODULE__, {:storage_type, 0}) ->
@impl Ash.Type
def storage_type(_constraints), do: storage_type()
true ->