Skip to content

Commit

Permalink
Revert "chore: undo change to bulk destroy omitting changeset.filter"
Browse files Browse the repository at this point in the history
This reverts commit 6484881.
  • Loading branch information
zachdaniel committed Jul 17, 2024
1 parent 6484881 commit 1db2b0f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 0 additions & 6 deletions lib/ash/actions/destroy/bulk.ex
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,6 @@ defmodule Ash.Actions.Destroy.Bulk do
authorize_bulk_query(query, atomic_changeset, opts),
{:ok, atomic_changeset, query} <-
authorize_atomic_changeset(query, atomic_changeset, opts),
{query, atomic_changeset} <- add_changeset_filters(query, atomic_changeset),
{:ok, data_layer_query} <- Ash.Query.data_layer_query(query) do
case Ash.DataLayer.destroy_query(
data_layer_query,
Expand Down Expand Up @@ -753,10 +752,6 @@ defmodule Ash.Actions.Destroy.Bulk do
end
end

defp add_changeset_filters(query, changeset) do
{Ash.Query.do_filter(query, changeset.filter), %{changeset | filter: nil}}
end

defp set_strategy(opts, resource, inputs_is_enumerable? \\ false) do
opts =
if Ash.DataLayer.data_layer_can?(resource, :update_query) do
Expand Down Expand Up @@ -1099,7 +1094,6 @@ defmodule Ash.Actions.Destroy.Bulk do
resource
|> Ash.Changeset.new()
|> Map.put(:domain, domain)
|> Ash.Changeset.filter(opts[:filter])
|> Ash.Actions.Helpers.add_context(opts)
|> Ash.Changeset.set_context(opts[:context] || %{})
|> Ash.Changeset.prepare_changeset_for_action(action, opts)
Expand Down
8 changes: 8 additions & 0 deletions lib/ash/data_layer/ets/ets.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1235,6 +1235,14 @@ defmodule Ash.DataLayer.Ets do
log_destroy_query(resource, query)

query
|> Map.update!(:filter, fn filter ->
if is_nil(changeset.filter) do
filter
else
filter = filter || %Ash.Filter{resource: changeset.resource}
Ash.Filter.add_to_filter!(filter, changeset.filter)
end
end)
|> run_query(resource)
|> case do
{:ok, results} ->
Expand Down

0 comments on commit 1db2b0f

Please sign in to comment.