fix: use ecto's uuid type under the hood

This commit is contained in:
Zach Daniel 2021-03-20 16:27:11 -04:00
parent 49039a1759
commit f1a6fb7418

View file

@ -8,24 +8,24 @@ defmodule Ash.Type.UUID do
use Ash.Type
@impl true
def storage_type, do: :binary_id
def storage_type, do: Ecto.UUID
@impl true
def cast_input(value, _) when is_binary(value) do
Ecto.Type.cast(:binary_id, String.trim(value))
Ecto.Type.cast(Ecto.UUID, String.trim(value))
end
def cast_input(value, _) do
Ecto.Type.cast(:binary_id, value)
Ecto.Type.cast(Ecto.UUID, value)
end
@impl true
def cast_stored(value, _) do
Ecto.Type.load(:binary_id, value)
Ecto.Type.load(Ecto.UUID, value)
end
@impl true
def dump_to_native(value, _) do
Ecto.Type.dump(:binary_id, value)
Ecto.Type.dump(Ecto.UUID, value)
end
end