Skip to content

Commit

Permalink
refactor: return empty list when filtering for non-public data #329
Browse files Browse the repository at this point in the history
  • Loading branch information
VKTB committed Feb 16, 2022
1 parent d8725ab commit 5f65725
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions datagateway_api/src/search_api/query_filter_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,14 @@ def get_where_filter(where_filter_input, entity_name):
where_filter_input,
)

# Ignore filters on `isPublic`` fields as data is always public. This is
# hardcoded in the `models.py` module.
if field != "isPublic":
# Ignore filters on `isPublic`` fields as data is always public. Ensure that
# empty list is returned when filtering for non-public data.
if field == "isPublic":
value = not value if operation == "neq" else value
if not value:
where_filters.append(SearchAPISkipFilter(1))
where_filters.append(SearchAPILimitFilter(0))
else:
where_filters.append(SearchAPIWhereFilter(field, value, operation))

return where_filters
Expand Down

0 comments on commit 5f65725

Please sign in to comment.