Skip to content

Commit

Permalink
#193: Add NOT like operation to WHERE filter on ICAT backend
Browse files Browse the repository at this point in the history
  • Loading branch information
MRichards99 committed Jan 7, 2021
1 parent b11001d commit 2d33c0c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions datagateway_api/common/icat/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ def create_filter(self):
where_filter = self.create_condition(self.field, "!=", self.value)
elif self.operation == "like":
where_filter = self.create_condition(self.field, "like", f"%{self.value}%")
elif self.operation == "nlike":
where_filter = self.create_condition(
self.field, "not like", f"%{self.value}%",
)
elif self.operation == "lt":
where_filter = self.create_condition(self.field, "<", self.value)
elif self.operation == "lte":
Expand Down
1 change: 1 addition & 0 deletions test/icat/filters/test_where_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class TestICATWhereFilter:
pytest.param("eq", 5, "= '5'", id="equal"),
pytest.param("ne", 5, "!= 5", id="not equal"),
pytest.param("like", 5, "like '%5%'", id="like"),
pytest.param("nlike", 5, "not like '%5%'", id="not like"),
pytest.param("lt", 5, "< '5'", id="less than"),
pytest.param("lte", 5, "<= '5'", id="less than or equal"),
pytest.param("gt", 5, "> '5'", id="greater than"),
Expand Down

0 comments on commit 2d33c0c

Please sign in to comment.