Skip to content

Commit

Permalink
fix: properly parse additional changeset expression
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel committed Apr 16, 2024
1 parent 371c2d1 commit 65675ef
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions lib/ash/changeset/changeset.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4903,23 +4903,24 @@ defmodule Ash.Changeset do
changeset
end

def filter(changeset, expr) do
def filter(changeset, expression) do
if Ash.DataLayer.data_layer_can?(changeset.resource, :changeset_filter) do
expression =
Ash.Expr.fill_template(
changeset.filter,
changeset.context[:private][:actor],
changeset.arguments,
changeset.context
)
expression = Ash.Filter.parse!(changeset.resource, expression)
expression =
Ash.Expr.fill_template(
expression,
changeset.context[:private][:actor],
changeset.arguments,
changeset.context
)

with {:ok, expression} <- Ash.Filter.hydrate_refs(expression, %{
resource: changeset.resource,
public?: false
}),
{:ok, expression} <- Ash.Filter.add_to_filter(
expression,
Ash.Filter.parse!(changeset.resource, expr)
changeset.filter,
expression
) do
%{changeset | filter: expression}
else
Expand Down

0 comments on commit 65675ef

Please sign in to comment.