Skip to content

Commit

Permalink
refactor: remove boolean_operator from SearchAPIWhereFilter #259
Browse files Browse the repository at this point in the history
- This is no longer used, boolean operators are managed by `NestedWhereFilters`
  • Loading branch information
MRichards99 committed Dec 6, 2021
1 parent 4134a16 commit 60cc5d1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
3 changes: 1 addition & 2 deletions datagateway_api/src/search_api/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@


class SearchAPIWhereFilter(PythonICATWhereFilter):
def __init__(self, field, value, operation, boolean_operator="and"):
def __init__(self, field, value, operation):
super().__init__(field, value, operation)
self.boolean_operator = boolean_operator

def apply_filter(self, query):
return super().apply_filter(query)
Expand Down
20 changes: 10 additions & 10 deletions test/search_api/test_nested_where_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,43 +76,43 @@ def test_str_filters(self, lhs, rhs, joining_operator, expected_where_clause):
"lhs, rhs, joining_operator, expected_where_clause",
[
pytest.param(
SearchAPIWhereFilter("name", "test name", "eq", "and"),
SearchAPIWhereFilter("id", 3, "eq", "and"),
SearchAPIWhereFilter("name", "test name", "eq"),
SearchAPIWhereFilter("id", 3, "eq"),
"OR",
"(o.name = 'test name' OR o.id = '3')",
id="(o.name = 'test name' OR o.id = '3')",
),
pytest.param(
[SearchAPIWhereFilter("name", "test name", "eq", "and")],
SearchAPIWhereFilter("id", 3, "eq", "and"),
[SearchAPIWhereFilter("name", "test name", "eq")],
SearchAPIWhereFilter("id", 3, "eq"),
"OR",
"(o.name = 'test name' OR o.id = '3')",
id="Single filter list in LHS",
),
pytest.param(
[SearchAPIWhereFilter("name", "test name", "eq", "and")],
[SearchAPIWhereFilter("id", 3, "eq", "and")],
[SearchAPIWhereFilter("name", "test name", "eq")],
[SearchAPIWhereFilter("id", 3, "eq")],
"OR",
"(o.name = 'test name' OR o.id = '3')",
id="Single filter list in LHS and RHS",
),
pytest.param(
[
SearchAPIWhereFilter("name", "test name", "eq", "and"),
SearchAPIWhereFilter("name", "test name", "eq"),
SearchAPIWhereFilter("id", 10, "lt"),
],
[SearchAPIWhereFilter("id", 3, "gt", "and")],
[SearchAPIWhereFilter("id", 3, "gt")],
"AND",
"(o.name = 'test name' AND o.id < '10' AND o.id > '3')",
id="Multiple filters on LHS",
),
pytest.param(
[
SearchAPIWhereFilter("name", "test name", "eq", "and"),
SearchAPIWhereFilter("name", "test name", "eq"),
SearchAPIWhereFilter("id", 10, "lt"),
],
[
SearchAPIWhereFilter("id", 3, "gt", "and"),
SearchAPIWhereFilter("id", 3, "gt"),
SearchAPIWhereFilter("doi", "Test DOI", "like"),
],
"AND",
Expand Down

0 comments on commit 60cc5d1

Please sign in to comment.