I can’t correctly pass values in between Ecto Multi run
calls.
Below I return {ok, bar |> Repo.preload(:baz)}
but in the next run
call, :baz
is not loaded:
Ecto.Multi.new()
|> Ecto.Multi.insert_or_update(:foo, foo_changeset)
|> Ecto.Multi.run(:add_something_to_foo, fn _repo, %{bar: bar} ->
# some code
{ok, bar |> Repo.preload(:baz)}
end)
|> Ecto.Multi.run(:add_something_else_to_foo, fn _repo, %{bar: bar} ->
IO.inspect bar # <---- `:baz` is not loaded
{ok, bar}
end)