Fix range function clauses

This commit is contained in:
Liam 2024-09-02 17:38:35 -04:00
parent f73befb439
commit 516f4a98fd

View file

@ -361,6 +361,9 @@ defmodule PhilomenaQuery.Parse.Parser do
{%{wildcard: %{field(parser, field_name) => normalize_value(parser, field_name, value)}}, {%{wildcard: %{field(parser, field_name) => normalize_value(parser, field_name, value)}},
[]}} []}}
defp field_type(_parser, [{LiteralParser, field_name}, _range, _value]),
do: {:error, "range specified for " <> field_name}
defp field_type(parser, [{NgramParser, field_name}, range: :eq, literal: value]), defp field_type(parser, [{NgramParser, field_name}, range: :eq, literal: value]),
do: do:
{:ok, {:ok,
@ -384,12 +387,21 @@ defmodule PhilomenaQuery.Parse.Parser do
{%{wildcard: %{field(parser, field_name) => normalize_value(parser, field_name, value)}}, {%{wildcard: %{field(parser, field_name) => normalize_value(parser, field_name, value)}},
[]}} []}}
defp field_type(_parser, [{NgramParser, field_name}, _range, _value]),
do: {:error, "range specified for " <> field_name}
defp field_type(parser, [{BoolParser, field_name}, range: :eq, bool: value]), defp field_type(parser, [{BoolParser, field_name}, range: :eq, bool: value]),
do: {:ok, {%{term: %{field(parser, field_name) => value}}, []}} do: {:ok, {%{term: %{field(parser, field_name) => value}}, []}}
defp field_type(_parser, [{BoolParser, field_name}, _range, _value]),
do: {:error, "range specified for " <> field_name}
defp field_type(parser, [{IpParser, field_name}, range: :eq, ip: value]), defp field_type(parser, [{IpParser, field_name}, range: :eq, ip: value]),
do: {:ok, {%{term: %{field(parser, field_name) => value}}, []}} do: {:ok, {%{term: %{field(parser, field_name) => value}}, []}}
defp field_type(_parser, [{IpParser, field_name}, _range, _value]),
do: {:error, "range specified for " <> field_name}
# Types which do support ranges # Types which do support ranges
defp field_type(parser, [{IntParser, field_name}, range: :eq, int: value]), defp field_type(parser, [{IntParser, field_name}, range: :eq, int: value]),