Skip to content

Commit

Permalink
#193: Add NOT like operatior for WHERE filter to DB backend
Browse files Browse the repository at this point in the history
  • Loading branch information
MRichards99 committed Jan 7, 2021
1 parent 2d33c0c commit 9455685
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions datagateway_api/common/database/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ def apply_filter(self, query):
query.base_query = query.base_query.filter(field != self.value)
elif self.operation == "like":
query.base_query = query.base_query.filter(field.like(f"%{self.value}%"))
elif self.operation == "nlike":
query.base_query = query.base_query.filter(field.notlike(f"%{self.value}%"))
elif self.operation == "lt":
query.base_query = query.base_query.filter(field < self.value)
elif self.operation == "lte":
Expand Down
1 change: 1 addition & 0 deletions test/db/test_query_filter_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def test_valid_skip_filter(self):
pytest.param({"where": {"ID": {"gte": "1"}}}, id="gte operator"),
pytest.param({"where": {"ID": {"in": ["1", "2", "3"]}}}, id="in operator"),
pytest.param({"where": {"ID": {"like": "3"}}}, id="like operator"),
pytest.param({"where": {"ID": {"nlike": "3"}}}, id="not like operator"),
pytest.param({"where": {"ID": {"lt": "1"}}}, id="lt operator"),
pytest.param({"where": {"ID": {"lte": "1"}}}, id="lte operator"),
],
Expand Down

0 comments on commit 9455685

Please sign in to comment.