From 516f4a98fd5167c91e1fa345c22a1fcf1c995586 Mon Sep 17 00:00:00 2001 From: Liam Date: Mon, 2 Sep 2024 17:38:35 -0400 Subject: [PATCH] Fix range function clauses --- lib/philomena_query/parse/parser.ex | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/philomena_query/parse/parser.ex b/lib/philomena_query/parse/parser.ex index e615653f..1b5f269d 100644 --- a/lib/philomena_query/parse/parser.ex +++ b/lib/philomena_query/parse/parser.ex @@ -361,6 +361,9 @@ defmodule PhilomenaQuery.Parse.Parser do {%{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]), do: {:ok, @@ -384,12 +387,21 @@ defmodule PhilomenaQuery.Parse.Parser do {%{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]), 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]), 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 defp field_type(parser, [{IntParser, field_name}, range: :eq, int: value]),