Skip to content

Commit

Permalink
fix: fix nested relations bug #261
Browse files Browse the repository at this point in the history
  • Loading branch information
MRichards99 committed Jan 26, 2022
1 parent 80a5ca7 commit 67fcbfe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
10 changes: 4 additions & 6 deletions datagateway_api/src/search_api/query_filter_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,15 +245,13 @@ def get_include_filter(include_filter_input, entity_name):
scope_query_filter, included_entity,
)
if isinstance(scope_query_filter, SearchAPIIncludeFilter):
for included_entity_pointer in range(
len(scope_query_filter.included_filters),
for i, included_filter in enumerate(
scope_query_filter.included_filters,
):
nested_include = True
included_filter = scope_query_filter.included_filters[
included_entity_pointer
]
scope_query_filter.panosc_entity_name = entity_name
scope_query_filter.included_filters[
included_entity_pointer
i
] = f"{included_entity}.{included_filter}"

query_filters.extend(scope_query_filters)
Expand Down
1 change: 1 addition & 0 deletions test/search_api/test_search_api_query_filter_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -1714,6 +1714,7 @@ def test_valid_include_filter_with_where_filter_in_scope(
assert len(filters) == expected_length
for test_filter in filters:
if isinstance(test_filter, SearchAPIIncludeFilter):
assert test_filter.panosc_entity_name == test_entity_name
for expected_include in expected_included_entities:
assert test_filter.included_filters == expected_include
expected_included_entities.remove(expected_include)
Expand Down

0 comments on commit 67fcbfe

Please sign in to comment.