Skip to content

Commit

Permalink
#145: Fix bug where GET requests without distinct filter sometimes r…
Browse files Browse the repository at this point in the history
…eturn a 400
  • Loading branch information
MRichards99 committed Oct 1, 2020
1 parent a4baba3 commit d3a0f0b
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions common/icat/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,13 @@ def entity_to_dict(self, entity, includes, distinct_fields=None):
" cause an issue further on in the request"
)
if isinstance(target, Entity):
distinct_fields_copy = self.prepare_distinct_fields_for_recursion(
key, distinct_fields
)
if distinct_fields is not None:
distinct_fields_copy = self.prepare_distinct_fields_for_recursion(
key, distinct_fields
)
else:
distinct_fields_copy = None

d[key] = self.entity_to_dict(
target, includes_copy, distinct_fields_copy
)
Expand All @@ -304,9 +308,13 @@ def entity_to_dict(self, entity, includes, distinct_fields=None):
elif isinstance(target, EntityList):
d[key] = []
for e in target:
distinct_fields_copy = self.prepare_distinct_fields_for_recursion(
key, distinct_fields
)
if distinct_fields is not None:
distinct_fields_copy = self.prepare_distinct_fields_for_recursion(
key, distinct_fields
)
else:
distinct_fields_copy = None

d[key].append(
self.entity_to_dict(e, includes_copy, distinct_fields_copy)
)
Expand Down

0 comments on commit d3a0f0b

Please sign in to comment.