Skip to content

Commit

Permalink
add support for nested AND/ OR #259
Browse files Browse the repository at this point in the history
  • Loading branch information
Viktor Bozhinov committed Nov 26, 2021
1 parent 68b85ef commit a590514
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions datagateway_api/src/search_api/query_filter_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,16 @@ def get_where_filter(filter_input, entity_name):
conditions = list(filter_input.values())[0]
for condition in conditions:
# Could be nested AND/OR
filter_data = SearchAPIQueryFilterFactory.get_condition_values(
condition,
where_filter = {
"filter": {"where": condition},
}
conditional_where_filters = SearchAPIQueryFilterFactory.get_query_filter(
where_filter, entity_name,
)
for condition in filter_data:
where_filters.append(
SearchAPIWhereFilter(
field=condition[0],
value=condition[1],
operation=condition[2],
boolean_operator=boolean_operator,
),
)

for conditional_where_filter in conditional_where_filters:
conditional_where_filter.boolean_operator = boolean_operator
where_filters.extend(conditional_where_filters)
elif list(filter_input.keys())[0] == "text":
# TODO - we might want to move this to the data
# definitions at a later point
Expand Down

0 comments on commit a590514

Please sign in to comment.