diff --git a/lib/ash/api/api.ex b/lib/ash/api/api.ex index fa3b5e9c3..358fb1729 100644 --- a/lib/ash/api/api.ex +++ b/lib/ash/api/api.ex @@ -1051,7 +1051,7 @@ defmodule Ash.Api do {:ok, true} end - %Ash.Changeset{data: data, action_type: type, resource: resource} + %Ash.Changeset{data: data, action_type: type, resource: resource, tenant: tenant} when type in [:update, :destroy] -> pkey = Ash.Resource.Info.primary_key(resource) pkey_value = Map.take(data, pkey) @@ -1061,6 +1061,7 @@ defmodule Ash.Api do else query |> Ash.Query.do_filter(pkey_value) + |> Ash.Query.set_tenant(tenant) |> Ash.Query.data_layer_query() |> case do {:ok, data_layer_query} -> diff --git a/lib/ash/filter/filter.ex b/lib/ash/filter/filter.ex index da416075a..d41357678 100644 --- a/lib/ash/filter/filter.ex +++ b/lib/ash/filter/filter.ex @@ -3463,6 +3463,15 @@ defmodule Ash.Filter do %__MODULE__{expression: expression} = filter -> %{filter | expression: move_to_relationship_path(expression, relationship_path)} + list when is_list(list) -> + Enum.map(list, &move_to_relationship_path(&1, relationship_path)) + + value when is_map(value) and not is_struct(value) -> + Map.new(value, fn {key, value} -> + {move_to_relationship_path(key, relationship_path), + move_to_relationship_path(value, relationship_path)} + end) + other -> other end