You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I have nested fields such that a.b and b are both legal expands, is_epxanded will not distinguish between b at the top level or nested
is_expanded will return true for all keys if ~all is in expanded, but ~all only expands top level expands
Proposed fix:
def is_expanded(expand, key):
"""Determine if the given key is expanded"""
expand_fields = []
# first split on commas to get each expand
for full in expand.split(","):
# than split on dots to get each component that is expanded
parts = full.split(".")
for i in range(len(parts)):
# add each prefix, as each prefix is epxanded, ie
# a.b.c will add a, a.b and a.b.c to the expand_fields list
# we do this to differentiate a.b from b
expand_fields.append(".".join(parts[: i + 1]))
# ~all only expands top level fields
if "." not in key and "~all" in expand_fields:
return True
return key in expand_fields
a.b
andb
are both legal expands,is_epxanded
will not distinguish betweenb
at the top level or nestedis_expanded
will return true for all keys if~all
is in expanded, but~all
only expands top level expandsProposed fix:
Test:
The text was updated successfully, but these errors were encountered: