Skip to content

Commit

Permalink
fix: don't use cast for changes
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel committed Oct 26, 2024
1 parent aff40b0 commit 879c8f1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/data_layer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2078,7 +2078,8 @@ defmodule AshPostgres.DataLayer do
record
|> to_ecto()
|> set_table(changeset, type, table_error?)
|> Ecto.Changeset.change(Map.take(changeset.attributes, attributes_to_change))
|> Ecto.Changeset.cast(%{}, [])
|> force_changes(Map.take(changeset.attributes, attributes_to_change))
|> add_configured_foreign_key_constraints(record.__struct__)
|> add_unique_indexes(record.__struct__, changeset)
|> add_check_constraints(record.__struct__)
Expand All @@ -2100,6 +2101,12 @@ defmodule AshPostgres.DataLayer do
end
end

defp force_changes(changeset, changes) do
Enum.reduce(changes, changeset, fn {key, value}, changeset ->
Ecto.Changeset.force_change(changeset, key, value)
end)
end

defp handle_raised_error(
%Ecto.StaleEntryError{changeset: %{data: %resource{}, filters: filters}},
stacktrace,
Expand Down

0 comments on commit 879c8f1

Please sign in to comment.