diff --git a/datagateway_api/common/icat/helpers.py b/datagateway_api/common/icat/helpers.py index 73472cc9..e7859406 100644 --- a/datagateway_api/common/icat/helpers.py +++ b/datagateway_api/common/icat/helpers.py @@ -553,6 +553,7 @@ def get_facility_cycles_for_instrument( query_aggregate = "COUNT:DISTINCT" if count_query else "DISTINCT" query = ICATQuery(client, "FacilityCycle", aggregate=query_aggregate) + query.isis_endpoint = True instrument_id_check = PythonICATWhereFilter( "facility.instruments.id", instrument_id, "eq", @@ -633,6 +634,7 @@ def get_investigations_for_instrument_in_facility_cycle( query_aggregate = "COUNT:DISTINCT" if count_query else "DISTINCT" query = ICATQuery(client, "Investigation", aggregate=query_aggregate) + query.isis_endpoint = True instrument_id_check = PythonICATWhereFilter( "facility.instruments.id", instrument_id, "eq", diff --git a/datagateway_api/common/icat/query.py b/datagateway_api/common/icat/query.py index 8da6c0fd..e57677f6 100644 --- a/datagateway_api/common/icat/query.py +++ b/datagateway_api/common/icat/query.py @@ -36,6 +36,9 @@ def __init__( :raises PythonICATError: If a ValueError is raised when creating a Query(), 500 will be returned as a response """ + # Needed for ISIS endpoints as they use DISTINCT keyword but don't select + # multiple attributes + self.isis_endpoint = False try: log.info("Creating ICATQuery for entity: %s", entity_name) @@ -93,6 +96,7 @@ def execute_query(self, client, return_json_formattable=False): self.query.aggregate == "DISTINCT" and not count_query and not self.query.manual_count + and not self.isis_endpoint ): distinct_query = True log.info("Extracting the distinct fields from query's conditions")