Skip to content

Commit

Permalink
fix: more fixes for atomic changeset context setting
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel committed May 4, 2024
1 parent 70f5264 commit 3b85451
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 8 additions & 2 deletions lib/ash/actions/destroy/bulk.ex
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,18 @@ defmodule Ash.Actions.Destroy.Bulk do
changeset

Ash.DataLayer.data_layer_can?(query.resource, :destroy_query) ->
private_context = %{
actor: opts[:actor],
tenant: opts[:tenant],
authorize?: opts[:authorize?]
}

opts =
Keyword.update(
opts,
:context,
%{private: query.context.private},
&Map.put(&1, :private, query.context.private)
%{private: private_context},
&Map.put(&1, :private, private_context)
)

Ash.Changeset.fully_atomic_changeset(query.resource, action, input, opts)
Expand Down
10 changes: 8 additions & 2 deletions lib/ash/actions/update/bulk.ex
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,18 @@ defmodule Ash.Actions.Update.Bulk do
changeset

Ash.DataLayer.data_layer_can?(query.resource, :update_query) ->
private_context = %{
actor: opts[:actor],
tenant: opts[:tenant],
authorize?: opts[:authorize?]
}

opts =
Keyword.update(
opts,
:context,
%{private: query.context.private},
&Map.put(&1, :private, query.context.private)
%{private: private_context},
&Map.put(&1, :private, private_context)
)

Ash.Changeset.fully_atomic_changeset(query.resource, action, input, opts)
Expand Down

0 comments on commit 3b85451

Please sign in to comment.