Skip to content

Commit

Permalink
Support :returning option in update (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
versilov authored Jul 6, 2020
1 parent ea18b1c commit fd0c3d9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/paper_trail/multi.ex
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ defmodule PaperTrail.Multi do
end)
|> Ecto.Multi.run(:model, fn repo, %{initial_version: initial_version} ->
updated_changeset = changeset |> change(%{current_version_id: initial_version.id})
repo.update(updated_changeset)
repo.update(updated_changeset, Keyword.take(options, [:returning]))
end)
|> Ecto.Multi.run(:version, fn repo, %{initial_version: initial_version} ->
new_item_changes =
Expand All @@ -99,7 +99,7 @@ defmodule PaperTrail.Multi do

_ ->
multi
|> Ecto.Multi.update(:model, changeset)
|> Ecto.Multi.update(:model, changeset, Keyword.take(options, [:returning]))
|> Ecto.Multi.run(:version, fn repo, %{model: _model} ->
version = make_version_struct(%{event: "update"}, changeset, options)
repo.insert(version)
Expand Down

0 comments on commit fd0c3d9

Please sign in to comment.