diff --git a/common/database_helpers.py b/common/database_helpers.py index 204c78e8..b9106145 100644 --- a/common/database_helpers.py +++ b/common/database_helpers.py @@ -5,7 +5,7 @@ from sqlalchemy import asc, desc from sqlalchemy.orm import aliased -from common.exceptions import MissingRecordError, BadFilterError, BadRequestError +from common.exceptions import MissingRecordError, BadFilterError, BadRequestError, MultipleIncludeError from common.models.db_models import INVESTIGATIONUSER, INVESTIGATION, INSTRUMENT, FACILITYCYCLE, \ INVESTIGATIONINSTRUMENT, FACILITY from common.session_manager import session_manager @@ -215,7 +215,10 @@ def __init__(self, included_filters): self.included_filters = included_filters["include"] def apply_filter(self, query): + if not query.include_related_entities: query.include_related_entities = True + else: + raise MultipleIncludeError("Attempted multiple includes on a single query") class QueryFilterFactory(object):