mirror of
https://github.com/ash-project/ash.git
synced 2024-09-19 21:13:10 +12:00
fix: fix runtime filter parsing & make last arg optional
This commit is contained in:
parent
2e2d2c404c
commit
f564e47fb8
1 changed files with 14 additions and 6 deletions
|
@ -174,7 +174,7 @@ defmodule Ash.Filter.Runtime do
|
|||
record
|
||||
|> flatten_relationships(relationship_paths)
|
||||
|> Enum.reduce_while({:ok, false}, fn scenario, {:ok, false} ->
|
||||
case do_match(scenario, expression, opts[:parent]) do
|
||||
case do_match(scenario, expression, opts[:parent], nil, opts[:unknown_on_unknown_refs?]) do
|
||||
{:error, error} ->
|
||||
{:halt, {:error, error}}
|
||||
|
||||
|
@ -1009,10 +1009,10 @@ defmodule Ash.Filter.Runtime do
|
|||
def get_related(
|
||||
source,
|
||||
path,
|
||||
unknown_on_unknown_refs? \\ false,
|
||||
unknown_on_unknown_refs?,
|
||||
join_filters \\ %{},
|
||||
parent_stack \\ [],
|
||||
api
|
||||
api \\ nil
|
||||
)
|
||||
|
||||
def get_related(nil, _, unknown_on_unknown_refs?, _join_filters, _parent_stack, _api) do
|
||||
|
@ -1062,9 +1062,17 @@ defmodule Ash.Filter.Runtime do
|
|||
end
|
||||
end)
|
||||
|
||||
api
|
||||
|> filter_matches(records, join_filter, parent: parent_stack)
|
||||
|> case do
|
||||
filtered =
|
||||
if Map.has_key?(join_filters, []) do
|
||||
filter_matches(api, records, join_filter,
|
||||
parent: parent_stack,
|
||||
unknown_on_unknown_refs?: unknown_on_unknown_refs?
|
||||
)
|
||||
else
|
||||
{:ok, records}
|
||||
end
|
||||
|
||||
case filtered do
|
||||
{:ok, matches} ->
|
||||
matches
|
||||
|> Enum.flat_map(fn match ->
|
||||
|
|
Loading…
Reference in a new issue