handle non-primary-key, non-assoc field (#39)

This commit is contained in:
Luiz Rodrigo de Souza 2024-10-09 22:19:14 -03:00 committed by GitHub
parent b0d53c117e
commit 1c0bd89955
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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)