mirror of
https://github.com/ash-project/ash.git
synced 2024-09-20 05:23:03 +12:00
fix: fix changing_attributes
check implementation
This commit is contained in:
parent
a7c865ed20
commit
2ef23840cc
2 changed files with 17 additions and 7 deletions
|
@ -38,24 +38,24 @@ defmodule Ash.Policy.Check.ChangingAttributes do
|
|||
|
||||
{{:ok, from}, {:ok, to}} ->
|
||||
if expr == true do
|
||||
{:cont, expr(not (^ref(attribute) == ^from and ^atomic_ref(attribute) == ^to))}
|
||||
{:cont, expr(^ref(attribute) == ^from and ^atomic_ref(attribute) == ^to)}
|
||||
else
|
||||
{:cont,
|
||||
expr(^expr and not (^ref(attribute) == ^from and ^atomic_ref(attribute) == ^to))}
|
||||
expr(^expr and ^ref(attribute) == ^from and ^atomic_ref(attribute) == ^to)}
|
||||
end
|
||||
|
||||
{{:ok, from}, :error} ->
|
||||
if expr == true do
|
||||
{:cont, expr(^ref(attribute) != ^from)}
|
||||
{:cont, expr(^ref(attribute) == ^from)}
|
||||
else
|
||||
{:cont, expr(^expr and ^ref(attribute) != ^from)}
|
||||
{:cont, expr(^expr and ^ref(attribute) == ^from)}
|
||||
end
|
||||
|
||||
{:error, {:ok, to}} ->
|
||||
if expr == true do
|
||||
{:cont, expr(^atomic_ref(attribute) != ^to)}
|
||||
{:cont, expr(^atomic_ref(attribute) == ^to)}
|
||||
else
|
||||
{:cont, expr(^expr and ^atomic_ref(attribute) != ^to)}
|
||||
{:cont, expr(^expr and ^atomic_ref(attribute) == ^to)}
|
||||
end
|
||||
end
|
||||
else
|
||||
|
|
|
@ -108,8 +108,18 @@ defmodule Ash.Policy.FilterCheck do
|
|||
|
||||
defp try_eval(expression, %{
|
||||
resource: resource,
|
||||
changeset: %Ash.Changeset{action_type: :create} = changeset
|
||||
changeset: %Ash.Changeset{action_type: :create} = changeset,
|
||||
actor: actor
|
||||
}) do
|
||||
expression =
|
||||
Ash.Expr.fill_template(
|
||||
expression,
|
||||
actor,
|
||||
changeset.arguments,
|
||||
changeset.context,
|
||||
changeset
|
||||
)
|
||||
|
||||
case Ash.Filter.hydrate_refs(expression, %{
|
||||
resource: resource,
|
||||
unknown_on_unknown_refs?: true,
|
||||
|
|
Loading…
Reference in a new issue