-
-
Notifications
You must be signed in to change notification settings - Fork 179
/
eq.ex
29 lines (25 loc) · 795 Bytes
/
eq.ex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
defmodule Ash.Query.Operator.Eq do
@moduledoc """
left == right
The simplest operator, matches if the left and right are equal.
For comparison, this compares as mutually exclusive with other equality
and `is_nil` checks that have the same reference on the left side
"""
use Ash.Query.Operator,
operator: :==,
name: :eq,
predicate?: true,
types: [:same, :any]
def evaluate(%{left: left, right: right}) do
{:known, Comp.equal?(left, right)}
end
def bulk_compare(predicates) do
predicates
|> Enum.filter(&match?(%struct{} when struct in [__MODULE__, Ash.Query.Operator.IsNil], &1))
|> Enum.uniq()
|> Enum.group_by(& &1.left)
|> Enum.flat_map(fn {_, predicates} ->
Ash.SatSolver.mutually_exclusive(predicates)
end)
end
end