fixes incorrectly handled type error when list of objects is found in data #9876

This commit is contained in:
Abhimanyu Saharan 2023-05-13 02:19:24 +05:30
parent e96cfadd22
commit cdbb3827fe

View File

@ -65,8 +65,14 @@ class Condition:
"""
Evaluate the provided data to determine whether it matches the condition.
"""
def _get(obj, key):
if isinstance(obj, list):
return [i.get(key) for i in obj]
return obj.get(key)
try:
value = functools.reduce(dict.get, self.attr.split('.'), data)
value = functools.reduce(_get, self.attr.split('.'), data)
except TypeError:
# Invalid key path
value = None