mirror of
https://github.com/ash-project/ash.git
synced 2024-09-20 13:33:20 +12:00
fix: convert %{__struct__: T}
into %T{}
(#947)
This commit is contained in:
parent
e6315e2928
commit
a85f559a20
3 changed files with 16 additions and 16 deletions
|
@ -26,7 +26,7 @@ defmodule Ash.Actions.Helpers do
|
|||
|
||||
def rollback_if_in_transaction(success, _, _), do: success
|
||||
|
||||
def validate_calculation_load!(%{__struct__: Ash.Query}, module) do
|
||||
def validate_calculation_load!(%Ash.Query{}, module) do
|
||||
raise """
|
||||
`#{inspect(module)}.load/3` returned a query.
|
||||
|
||||
|
@ -39,13 +39,13 @@ defmodule Ash.Actions.Helpers do
|
|||
|
||||
def validate_calculation_load!(other, _), do: other
|
||||
|
||||
defp set_context(%{__struct__: Ash.Changeset} = changeset, context),
|
||||
defp set_context(%Ash.Changeset{} = changeset, context),
|
||||
do: Ash.Changeset.set_context(changeset, context)
|
||||
|
||||
defp set_context(%{__struct__: Ash.Query} = query, context),
|
||||
defp set_context(%Ash.Query{} = query, context),
|
||||
do: Ash.Query.set_context(query, context)
|
||||
|
||||
defp set_context(%{__struct__: Ash.ActionInput} = action_input, context),
|
||||
defp set_context(%Ash.ActionInput{} = action_input, context),
|
||||
do: Ash.ActionInput.set_context(action_input, context)
|
||||
|
||||
def add_process_context(api, query_or_changeset, opts) do
|
||||
|
@ -117,19 +117,19 @@ defmodule Ash.Actions.Helpers do
|
|||
|> Map.put_new(:authorize?, false)
|
||||
|
||||
case query_or_changeset do
|
||||
%{__struct__: Ash.ActionInput} ->
|
||||
%Ash.ActionInput{} ->
|
||||
query_or_changeset
|
||||
|> Ash.ActionInput.set_context(context)
|
||||
|> Ash.ActionInput.set_context(%{private: private_context})
|
||||
|> Ash.ActionInput.set_tenant(query_or_changeset.tenant || opts[:tenant])
|
||||
|
||||
%{__struct__: Ash.Query} ->
|
||||
%Ash.Query{} ->
|
||||
query_or_changeset
|
||||
|> Ash.Query.set_context(context)
|
||||
|> Ash.Query.set_context(%{private: private_context})
|
||||
|> Ash.Query.set_tenant(query_or_changeset.tenant || opts[:tenant])
|
||||
|
||||
%{__struct__: Ash.Changeset} ->
|
||||
%Ash.Changeset{} ->
|
||||
query_or_changeset
|
||||
|> Ash.Changeset.set_context(context)
|
||||
|> Ash.Changeset.set_context(%{
|
||||
|
|
|
@ -83,7 +83,7 @@ defmodule Ash.Query.BooleanExpression do
|
|||
def optimized_new(
|
||||
:or,
|
||||
%Eq{left: left, right: value} = left_op,
|
||||
%In{left: left, right: %{__struct__: MapSet} = mapset} = right
|
||||
%In{left: left, right: %MapSet{} = mapset} = right
|
||||
) do
|
||||
if can_optimize?(value) do
|
||||
%{right | right: MapSet.put(mapset, value)}
|
||||
|
@ -95,7 +95,7 @@ defmodule Ash.Query.BooleanExpression do
|
|||
def optimized_new(
|
||||
:and,
|
||||
%Eq{left: left, right: value} = left_expr,
|
||||
%In{left: left, right: %{__struct__: MapSet} = mapset} = right
|
||||
%In{left: left, right: %MapSet{} = mapset} = right
|
||||
) do
|
||||
if can_optimize?(value) do
|
||||
if MapSet.member?(mapset, value) do
|
||||
|
@ -111,7 +111,7 @@ defmodule Ash.Query.BooleanExpression do
|
|||
def optimized_new(
|
||||
:and,
|
||||
%NotEq{left: left, right: value} = left_op,
|
||||
%In{left: left, right: %{__struct__: MapSet} = mapset} = right_expr
|
||||
%In{left: left, right: %MapSet{} = mapset} = right_expr
|
||||
) do
|
||||
if can_optimize?(value) do
|
||||
%{right_expr | right: MapSet.delete(mapset, value)}
|
||||
|
@ -166,8 +166,8 @@ defmodule Ash.Query.BooleanExpression do
|
|||
|
||||
def optimized_new(
|
||||
:or,
|
||||
%In{left: left, right: %{__struct__: MapSet} = left_values},
|
||||
%In{left: left, right: %{__struct__: MapSet} = right_values} = right_expr
|
||||
%In{left: left, right: %MapSet{} = left_values},
|
||||
%In{left: left, right: %MapSet{} = right_values} = right_expr
|
||||
) do
|
||||
%{right_expr | right: MapSet.union(left_values, right_values)}
|
||||
end
|
||||
|
@ -318,7 +318,7 @@ defmodule Ash.Query.BooleanExpression do
|
|||
end)
|
||||
end
|
||||
|
||||
defp can_optimize?(%{__struct__: MapSet} = mapset) do
|
||||
defp can_optimize?(%MapSet{} = mapset) do
|
||||
Enum.all?(mapset, &can_optimize?/1)
|
||||
end
|
||||
|
||||
|
|
|
@ -611,8 +611,8 @@ defmodule Ash.SatSolver do
|
|||
def split_in_expressions(other, _), do: other
|
||||
|
||||
def overlap?(
|
||||
%Ash.Query.Operator.In{left: left, right: %{__struct__: MapSet} = left_right},
|
||||
%Ash.Query.Operator.In{left: left, right: %{__struct__: MapSet} = right_right}
|
||||
%Ash.Query.Operator.In{left: left, right: %MapSet{} = left_right},
|
||||
%Ash.Query.Operator.In{left: left, right: %MapSet{} = right_right}
|
||||
) do
|
||||
if MapSet.equal?(left_right, right_right) do
|
||||
false
|
||||
|
@ -639,7 +639,7 @@ defmodule Ash.SatSolver do
|
|||
|
||||
def overlap?(
|
||||
%Ash.Query.Operator.Eq{left: left, right: left_right},
|
||||
%Ash.Query.Operator.In{left: left, right: %{__struct__: MapSet} = right_right}
|
||||
%Ash.Query.Operator.In{left: left, right: %MapSet{} = right_right}
|
||||
) do
|
||||
MapSet.member?(right_right, left_right)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue