Skip to content

Commit 1f8d6e8

Browse files
committed
Fix _serialize_depends_on to handle bare dict depends_on
MATLAB's jsonencode converts single-element cell arrays to scalars, so depends_on can arrive as a bare dict instead of a list. Normalize it to a single-element list in both _serialize_depends_on and doc_to_sql for defense in depth. https://claude.ai/code/session_01UbcbwwRqiY8mCMRf2pEsWg
1 parent cfbf786 commit 1f8d6e8

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/did/implementations/doc2sql.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ def _get_superclass_str(doc_props):
8989
def _serialize_depends_on(doc_props):
9090
"""Serialize depends_on matching MATLAB's format: 'name,value;name,value;'"""
9191
depends_on = doc_props.get("depends_on", [])
92+
if isinstance(depends_on, dict):
93+
depends_on = [depends_on]
9294
if not depends_on or not isinstance(depends_on, list):
9395
return ""
9496

@@ -153,6 +155,11 @@ def doc_to_sql(doc):
153155
"""
154156
doc_props = doc.document_properties
155157

158+
# Normalize bare dict depends_on to a list (MATLAB's jsonencode converts
159+
# single-element cell arrays to scalars).
160+
if isinstance(doc_props.get("depends_on"), dict):
161+
doc_props["depends_on"] = [doc_props["depends_on"]]
162+
156163
# Build the 'meta' table
157164
meta = {"name": "meta", "columns": []}
158165

0 commit comments

Comments
 (0)