From 1c0bd899557a7d53cf89c3b6f626865aabf8d72e Mon Sep 17 00:00:00 2001 From: Luiz Rodrigo de Souza Date: Wed, 9 Oct 2024 22:19:14 -0300 Subject: [PATCH] handle non-primary-key, non-assoc field (#39) --- lib/type_id/ecto.ex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/type_id/ecto.ex b/lib/type_id/ecto.ex index c7d6fc9..4137fe2 100644 --- a/lib/type_id/ecto.ex +++ b/lib/type_id/ecto.ex @@ -114,11 +114,11 @@ if Code.ensure_loaded?(Ecto.ParameterizedType) do if primary_key do %{primary_key: primary_key, schema: schema, field: field, prefix: prefix, type: type} else - %{schema: schema, field: field, type: type} + %{schema: schema, field: field, type: type, prefix: prefix} end end - defp find_prefix(%{prefix: prefix}), do: prefix + defp find_prefix(%{prefix: prefix}) when not is_nil(prefix), do: prefix defp find_prefix(%{schema: schema, field: field}) do %{related: schema, related_key: field} = schema.__schema__(:association, field)