Skip to content

Commit bb84d9e

Browse files
authored
fix: unsupported error for empty string and dict
closes #11
1 parent a186a47 commit bb84d9e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

firebase/firestore/_utils.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@ def _from_datastore(data):
2929

3030
for key, val in data_to_restructure.items():
3131

32-
if val.get('mapValue'):
33-
data_to_restructure[key] = _from_datastore(val['mapValue'])
32+
if isinstance(val.get('mapValue'), dict):
33+
34+
if val['mapValue'].get('fields', False):
35+
data_to_restructure[key] = _from_datastore(val['mapValue'])
36+
else:
37+
data_to_restructure[key] = {}
3438

3539
elif isinstance(val.get('arrayValue'), dict):
3640
arr = []
@@ -81,7 +85,7 @@ def _decode_datastore(value):
8185
elif value.get('doubleValue'):
8286
return float(value['doubleValue'])
8387

84-
elif value.get('stringValue'):
88+
elif isinstance(value.get('stringValue'), str):
8589
return str(value['stringValue'])
8690

8791
elif value.get('mapValue'):

0 commit comments

Comments
 (0)