Skip to content

Commit

Permalink
Fix post-compile assoc validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo B committed Apr 25, 2023
1 parent b533d92 commit c686f91
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/ecto/association.ex
Original file line number Diff line number Diff line change
Expand Up @@ -727,10 +727,13 @@ defmodule Ecto.Association do
defp primary_key!(struct), do: Ecto.primary_key!(struct)

def missing_fields(queryable, related_key) do
Enum.filter related_key, &is_nil(queryable.__schema__(:type, &1))
related_key
|> List.wrap()
|> Enum.filter(&is_nil(queryable.__schema__(:type, &1)))
end

def missing_primary_keys(queryable, related_key) do
related_key = List.wrap related_key
Enum.reject queryable.__schema__(:primary_key), &(&1 in related_key)
end

Expand Down

0 comments on commit c686f91

Please sign in to comment.