fix: optimize filter expr traversal

This commit is contained in:
Zach Daniel 2024-08-15 19:36:58 -04:00
parent a86ef00521
commit 5a6583a019

View file

@ -1166,12 +1166,6 @@ defmodule Ash.Filter do
value when is_list(value) ->
Enum.map(value, &map(&1, func))
value when is_map(value) ->
value
|> Map.to_list()
|> map(func)
|> Map.new()
%BooleanExpression{left: left, right: right} = expr ->
%{expr | left: map(left, func), right: map(right, func)}
@ -1210,6 +1204,16 @@ defmodule Ash.Filter do
end)
}
%Ash.Query.Ref{} = expr ->
# you have to map over the internals of exists yourself
func.(expr)
value when is_map(value) ->
value
|> Map.to_list()
|> map(func)
|> Map.new()
other ->
func.(other)
end