Skip to content

Commit ee67736

Browse files
fix: harden list-of-dict type checks in flatten paths by reviewer-B
1 parent 4ae9b15 commit ee67736

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎src/json2sql/converter.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def _convert_objects(self, objects: list[dict], table_name: str) -> str:
8484
# Process nested arrays into child tables
8585
for obj in objects:
8686
for key, value in obj.items():
87-
if isinstance(value, list) and value and isinstance(value[0], dict):
87+
if isinstance(value, list) and value and all(isinstance(v, dict) for v in value):
8888
self._flatten_nested(table_name, key, value, obj)
8989
else:
9090
columns = self._infer_columns(objects)
@@ -216,5 +216,5 @@ def _process_flatten(self, objects: list, table_name: str) -> None:
216216
return
217217
for obj in objects:
218218
for key, value in obj.items():
219-
if isinstance(value, list) and value and isinstance(value[0], dict):
219+
if isinstance(value, list) and value and all(isinstance(v, dict) for v in value):
220220
self._flatten_nested(table_name, key, value, obj)

0 commit comments

Comments
 (0)