Skip to content

Commit

Permalink
feat: implement between operator #297
Browse files Browse the repository at this point in the history
  • Loading branch information
VKTB committed Jan 19, 2022
1 parent 8267de0 commit 4736888
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions datagateway_api/src/datagateway_api/icat/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ def create_filter(self):
self.value = "(NULL)"

where_filter = self.create_condition(self.field, "in", self.value)
elif self.operation == "between":
where_filter = self.create_condition(
self.field, "between", f"'{self.value[0]}' and '{self.value[1]}'",
)
else:
raise FilterError(f"Bad operation given to where filter: {self.operation}")

Expand Down Expand Up @@ -116,8 +120,7 @@ def create_condition(attribute_name, operator, value):
# distinct filter is used in a request
jpql_value = (
f"{value}"
if operator == "in"
or operator == "!="
if operator in ("in", "not in", "!=", "between")
or str(value).startswith("UPPER")
or "o." in str(value)
else f"'{value}'"
Expand Down

0 comments on commit 4736888

Please sign in to comment.