- Add pattern match for models when serialize association
- Add pattern match for changesets when dump field
- Do not serialize nested associations when action is
update
and changes are empty - Add
event
anddata
info when serializing an association withaction == :replace
- Add
event
andchanges
info when serializing an association withaction != :replace
Before, when serializing nested associations, we could have empty maps in the JSON, since we were only serializing the changes
from the Changeset. Now we have more information about whats going on on these associations.
Suppose we have a Post struct and a Comment struct that is associated with Post (with has_many
):
%Post{
title: "Example post",
description: "...",
comments: [
%{Comment{id: 1, text: "comment 1"},
%{Comment{id: 2, text: "comment 2"},
%{Comment{id: 3, text: "comment 3"},
]
}
# Now we update the posts with these attrs:
%{comments: [
%{id: 1, text: "comment 1 updated"},
%{id: 2, text: "comment 2"},
%{text: "new comment"},
]}
# before, the serialized `item_changes` in the `versions` table would be:
%{"comments" => [
{"text" => "comment 1 updated"},
{}, # this is the comment 2, without any changes
{}, # This is the comment 3, deleted because it was not in the attrs and there's no changes in the Changeset. changeset.action is set to replace
{"text" => "new comment"},
]}
# now, it will be serialized as this:
%{"comments" => [
{"event" => "update", "changes" => %{"text" => "comment 1 updated"}},
{"event" => "replace", "data" => %{"text" => "comment 3"}},
{"event" => "insert", "changes" => %{"text" => "new comment"}},
]}
# Notice that we removed serialization of associations with empty changes when it's an update action.
- Add support for Ecto 3.9.0
- Add support for Ecto 3.8
- Remove workaround from v0.11.1
- Add workaround for wrong
Ecto.Multi.insert_all
typespec (elixir-ecto/ecto#3781)
- Chunk attributes when doing
insert_all
to not reach Postgres limit of 65535 query parameters.
- Save changes for nested associations.
- Deal with changes that have embedded schemas.
- Get the correct type of
originator_id
when building versions for update.
- Support multiple Repos.
- Support
update_all
operation. - Improve serialization for non string Ecto types.
- Do not create version when there are no changes.
- PaperTrail.delete now accepts Ecto.Changeset
- Rare PaperTrail.RepoClient.repo compile time errors fixed.
- Version event names are now 'insert', 'update', 'delete' to match their Ecto counterpats instead of 'create', 'update', 'destroy'.
- Introduction of strict mode. Please read the documentation for more information on the required origin and originator_id field and foreign-key references.