diff --git a/datagateway_api/src/search_api/filters.py b/datagateway_api/src/search_api/filters.py index 474326a0..99b1195c 100644 --- a/datagateway_api/src/search_api/filters.py +++ b/datagateway_api/src/search_api/filters.py @@ -41,9 +41,7 @@ def apply_filter(self, query): # code written in `PythonICATWhereFilter.apply_filter()` self.field = ".".join(icat_field_names) - # TODO - `query.query.query` might be confusing, might rename `query` in - # function signature - return super().apply_filter(query.query.query) + return super().apply_filter(query.icat_query.query) def get_icat_mapping(self, panosc_entity_name, field_name): """ @@ -113,12 +111,12 @@ def __str__(self): # Replicating the condition in Python ICAT format so it can be searched on # the query and return as string representation conds_dict = self.create_filter() - a, jpql_func = query.query.query._split_db_functs(self.field) - conds_dict[self.field] = query.query.query._cond_value( + a, jpql_func = query.icat_query.query._split_db_functs(self.field) + conds_dict[self.field] = query.icat_query.query._cond_value( conds_dict[self.field], jpql_func, ) - str_conds = query.query.query.search_conditions(self.field, conds_dict) + str_conds = query.icat_query.query.search_conditions(self.field, conds_dict) try: return str_conds[0] @@ -139,7 +137,7 @@ def __init__(self, skip_value): super().__init__(skip_value, filter_use="search_api") def apply_filter(self, query): - return super().apply_filter(query.query.query) + return super().apply_filter(query.icat_query.query) class SearchAPILimitFilter(PythonICATLimitFilter): @@ -147,7 +145,7 @@ def __init__(self, limit_value): super().__init__(limit_value) def apply_filter(self, query): - return super().apply_filter(query.query.query) + return super().apply_filter(query.icat_query.query) class SearchAPIIncludeFilter(PythonICATIncludeFilter): @@ -155,4 +153,4 @@ def __init__(self, included_filters): super().__init__(included_filters) def apply_filter(self, query): - return super().apply_filter(query.query.query) + return super().apply_filter(query.icat_query.query) diff --git a/datagateway_api/src/search_api/helpers.py b/datagateway_api/src/search_api/helpers.py index 0eb07f77..abd606d0 100644 --- a/datagateway_api/src/search_api/helpers.py +++ b/datagateway_api/src/search_api/helpers.py @@ -24,7 +24,7 @@ def get_search(endpoint_name, entity_name, filters=list()): filter_handler.add_query_to_where_filters(query) filter_handler.apply_filters(query) - log.debug("Python ICAT Query: %s", query.query.query) + log.debug("Python ICAT Query: %s", query.icat_query.query) # TODO - `getApiVersion()` used as a placeholder for testing client handling # Replace with endpoint functionality when implementing the endpoints return SessionHandler.client.getApiVersion() diff --git a/datagateway_api/src/search_api/nested_where_filters.py b/datagateway_api/src/search_api/nested_where_filters.py index 1748f253..8d70b7de 100644 --- a/datagateway_api/src/search_api/nested_where_filters.py +++ b/datagateway_api/src/search_api/nested_where_filters.py @@ -42,7 +42,7 @@ def __init__(self, lhs, rhs, joining_operator, search_api_query=None): NestedWhereFilters.set_search_api_query(self, search_api_query) def apply_filter(self, query): - query.query.query.setConditionsByString(str(self)) + query.icat_query.query.setConditionsByString(str(self)) @staticmethod def set_search_api_query(query_filter, search_api_query): diff --git a/datagateway_api/src/search_api/query.py b/datagateway_api/src/search_api/query.py index b8dd9ba5..9b4840be 100644 --- a/datagateway_api/src/search_api/query.py +++ b/datagateway_api/src/search_api/query.py @@ -11,4 +11,4 @@ def __init__(self, panosc_entity_name): "base_icat_entity" ] - self.query = ICATQuery(SessionHandler.client, self.icat_entity_name) + self.icat_query = ICATQuery(SessionHandler.client, self.icat_entity_name) diff --git a/test/search_api/filters/test_search_api_limit_filter.py b/test/search_api/filters/test_search_api_limit_filter.py index 36f15cc4..6c88452f 100644 --- a/test/search_api/filters/test_search_api_limit_filter.py +++ b/test/search_api/filters/test_search_api_limit_filter.py @@ -19,7 +19,7 @@ def test_valid_limit_value(self, limit_value): test_query = SearchAPIQuery("Document") test_filter.apply_filter(test_query) - assert test_query.query.query.limit == (0, limit_value) + assert test_query.icat_query.query.limit == (0, limit_value) @pytest.mark.parametrize( "limit_value", diff --git a/test/search_api/filters/test_search_api_skip_filter.py b/test/search_api/filters/test_search_api_skip_filter.py index b7902064..f49742c1 100644 --- a/test/search_api/filters/test_search_api_skip_filter.py +++ b/test/search_api/filters/test_search_api_skip_filter.py @@ -19,7 +19,7 @@ def test_valid_skip_value(self, icat_query, skip_value): test_query = SearchAPIQuery("Document") test_filter.apply_filter(test_query) - assert test_query.query.query.limit == ( + assert test_query.icat_query.query.limit == ( skip_value, get_icat_properties( Config.config.search_api.icat_url, diff --git a/test/search_api/filters/test_search_api_where_filter.py b/test/search_api/filters/test_search_api_where_filter.py index 06a762fe..a1a0f97b 100644 --- a/test/search_api/filters/test_search_api_where_filter.py +++ b/test/search_api/filters/test_search_api_where_filter.py @@ -95,9 +95,9 @@ def test_valid_apply_where_filter(self, filter_input, entity_name, expected_quer filter_handler.apply_filters(test_query) - print(f"JPQL Query: {str(test_query.query.query)}") + print(f"JPQL Query: {str(test_query.icat_query.query)}") - assert expected_query == str(test_query.query.query) + assert expected_query == str(test_query.icat_query.query) @pytest.mark.parametrize( "filter_input, entity_name, expected_query", @@ -194,6 +194,6 @@ def test_valid_apply_nested_filters( filter_handler.apply_filters(test_query) - print(f"JPQL Query: {str(test_query.query.query)}") + print(f"JPQL Query: {str(test_query.icat_query.query)}") - assert str(test_query.query.query) == expected_query + assert str(test_query.icat_query.query) == expected_query