Skip to content

Commit

Permalink
Merge pull request #15 from nash-io/do-not-serialize-array-of-uuid
Browse files Browse the repository at this point in the history
Do not serialize array of UUID
  • Loading branch information
adrienmo authored Jan 12, 2023
2 parents 8db5b77 + b122585 commit 6de8d8d
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/paper_trail/serializer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,16 @@ defmodule PaperTrail.Serializer do
{alias, type} = Map.fetch!(dumper, field)

dumped_value =
if(
type in ignored_ecto_types(),
do: serialize_binary(value),
else: do_dump_field!(schema, field, type, value, adapter)
)
cond do
match?({:array, _}, type) and Enum.any?(ignored_ecto_types(), & type == {:array, &1}) ->
Enum.map(value, &serialize_binary/1)

type in ignored_ecto_types() ->
serialize_binary(value)

true ->
do_dump_field!(schema, field, type, value, adapter)
end

{alias, dumped_value}
end
Expand Down

0 comments on commit 6de8d8d

Please sign in to comment.