Fix empty projection handling

This commit is contained in:
allegroai 2020-08-10 08:56:43 +03:00
parent dccf9dd8f8
commit 0146ded4f4

View File

@ -353,9 +353,12 @@ class GetMixin(PropsMixin):
cls, projection: Sequence[str]
) -> Tuple[Collection[str], Collection[str]]:
"""Return include and exclude lists based on passed projection and class definition"""
if projection:
include, exclude = partition(
projection, key=lambda x: x[0] != ProjectionHelper.exclusion_prefix,
)
else:
include, exclude = [], []
exclude = {x.lstrip(ProjectionHelper.exclusion_prefix) for x in exclude}
return include, set(cls.get_exclude_fields()).union(exclude).difference(include)