From 262f47cd6c527918363a0c13d095e294a40c5640 Mon Sep 17 00:00:00 2001 From: Luiz Rodrigo de Souza Date: Wed, 30 Oct 2024 20:18:30 -0300 Subject: [PATCH] better support for default type --- lib/type_id/ecto.ex | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/type_id/ecto.ex b/lib/type_id/ecto.ex index 815bc2e..114d529 100644 --- a/lib/type_id/ecto.ex +++ b/lib/type_id/ecto.ex @@ -110,6 +110,10 @@ if Code.ensure_loaded?(Ecto.ParameterizedType) do nil -> opts |> Keyword.get(:type, default_type) + |> case do + TypeID -> default_type + type -> type + end |> validate_type!() type -> @@ -118,6 +122,7 @@ if Code.ensure_loaded?(Ecto.ParameterizedType) do end defp validate_opts!(opts) do + IO.inspect(opts) primary_key = Keyword.get(opts, :primary_key, false) schema = Keyword.fetch!(opts, :schema) field = Keyword.fetch!(opts, :field) @@ -133,6 +138,7 @@ if Code.ensure_loaded?(Ecto.ParameterizedType) do else %{schema: schema, field: field, type: type, prefix: prefix} end + |> IO.inspect() end defp find_prefix(%{prefix: prefix}) when not is_nil(prefix), do: prefix