fix: don't clobber loaded data on update

This commit is contained in:
Zach Daniel 2023-08-31 13:04:08 -04:00
parent 9ae51b6c06
commit 9f77304b22
2 changed files with 7 additions and 2 deletions

View file

@ -1993,6 +1993,13 @@ defmodule AshPostgres.DataLayer do
)}
{1, [record]} ->
record =
changeset.resource
|> Ash.Resource.Info.attributes()
|> Enum.reduce(changeset.data, fn attribute, data ->
Map.put(data, attribute.name, Map.get(record, attribute.name))
end)
maybe_update_tenant(resource, changeset, record)
{:ok, record}

View file

@ -519,8 +519,6 @@ defmodule AshPostgres.CalculationTest do
end
test "nested get_path works" do
Logger.configure(level: :debug)
assert "thing" =
Post
|> Ash.Changeset.new(%{title: "match", price: 10_024, stuff: %{foo: %{bar: "thing"}}})