Skip to content

Commit

Permalink
#39: Raise exception if multiple includes applied
Browse files Browse the repository at this point in the history
  • Loading branch information
keiranjprice101 committed Sep 18, 2019
1 parent 13ac77e commit 31e5b6e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion common/database_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 31e5b6e

Please sign in to comment.