Skip to content

Commit 63cce77

Browse files
fix: unsupported type error thrown for empty array field
resolves #7.
1 parent 8c911a7 commit 63cce77

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

firebase/firestore/_utils.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@ def _from_datastore(data):
3232
if val.get('mapValue'):
3333
data_to_restructure[key] = _from_datastore(val['mapValue'])
3434

35-
elif val.get('arrayValue'):
35+
elif isinstance(val.get('arrayValue'), dict):
3636
arr = []
3737

38-
for x in val['arrayValue']['values']:
39-
arr.append(_decode_datastore(x))
38+
if val['arrayValue'].get('values'):
39+
for x in val['arrayValue']['values']:
40+
arr.append(_decode_datastore(x))
4041

4142
data_to_restructure[key] = arr
4243

tests/test_firestore.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ class TestFirestoreAuth:
105105
'year': 2016,
106106
'rating': 7.5,
107107
'prequel': None,
108-
'cast': ['Tilda Swinton', 'Rachel McAdams', 'Mads Mikkelsen', 'Chiwetel Ejiofor', 'Benedict Wong']
108+
'cast': ['Tilda Swinton', 'Rachel McAdams', 'Mads Mikkelsen', 'Chiwetel Ejiofor', 'Benedict Wong'],
109+
'producers': []
109110
}
110111

111112
movies2 = {

0 commit comments

Comments
 (0)