mirror of
https://github.com/ash-project/ash.git
synced 2024-09-21 05:53:06 +12:00
f6f5d194bf
feat: validatiosn in actions feat: query arguments feat: add `Ash.Query.for_read/3` feat: return changeset with API errors feat: add case insensitive string `CiString`/`:ci_string` feat: support `context/1` and `arg/1` in filter templates feat: support targeting notifications with the `for` option feat: add `ago/2` query function feat: add basic arithmetic operators (+, *, -, /) feat: `sensitive?` option for attributes feat: `sensitive?` option for arguments feat: `private` arguments, which can’t be set using `for_<action>` feat: add `prevent_change` which will erase changes just before the changeset is committed feat: add `match?` validation that supports a custom error message feat: add `interval` type to support `ago/2` function feat: add `url_encoded_binary` type feat: add `function` type improvement: `changing?` is now a validation improvement: add `Transformer.get_persisted/3` improvement: add `api` field to `Notification` improvement: standardize errors, add `to_error_class` improvement: use `Comp` everywhere Improvement: use action on changeset if set by `for_<action_type>` improvement: `action_failed?` field on change sets improvement: remove ability for data layers to add operators (for now at least) Improvement: Changeset.apply_attributes/2 now returns an error tuple Improvement: add a bunch of new/informative errors improvement: runtime filter now uses left join logic (a naive implementation of it) improvement: support more filter templates in resources Improvement: basic/naive type system for operators/functions Fix: properly expand module aliases for options w/o compile time dependency chore(engine): track changeset changes for the request with `manage_changeset?: true`
58 lines
1.3 KiB
Elixir
58 lines
1.3 KiB
Elixir
defmodule Ash.Query.Operator.IsNil do
|
|
@moduledoc """
|
|
left is_nil true/false
|
|
|
|
This predicate matches if the left is nil when the right is `true` or if the
|
|
left is not nil when the right is `false`
|
|
"""
|
|
use Ash.Query.Operator,
|
|
operator: :is_nil,
|
|
predicate?: true,
|
|
types: [[:any, :boolean]]
|
|
|
|
def evaluate(%{left: left, right: is_nil?}) do
|
|
{:known, is_nil(left) == is_nil?}
|
|
end
|
|
|
|
def to_string(%{left: left, right: right}, opts) do
|
|
import Inspect.Algebra
|
|
|
|
text =
|
|
if right do
|
|
" is nil"
|
|
else
|
|
" is not nil"
|
|
end
|
|
|
|
concat([
|
|
to_doc(left, opts),
|
|
text
|
|
])
|
|
end
|
|
|
|
def compare(%__MODULE__{left: %Ref{} = same_ref, right: true}, %Ash.Query.Operator.Eq{
|
|
left: %Ref{} = same_ref,
|
|
right: nil
|
|
}) do
|
|
:mutually_inclusive
|
|
end
|
|
|
|
def compare(%__MODULE__{left: %Ref{} = same_ref, right: false}, %Ash.Query.Operator.Eq{
|
|
left: %Ref{} = same_ref,
|
|
right: nil
|
|
}) do
|
|
:mutually_exclusive
|
|
end
|
|
|
|
def compare(%__MODULE__{left: %Ref{} = same_ref, right: false}, %Ash.Query.Operator.Eq{
|
|
left: %Ref{} = same_ref
|
|
}) do
|
|
:right_includes_left
|
|
end
|
|
|
|
def compare(%__MODULE__{left: %Ref{} = same_ref}, %__MODULE__{left: %Ref{} = same_ref}) do
|
|
:mutually_exclusive
|
|
end
|
|
|
|
def compare(_, _), do: :unknown
|
|
end
|