Skip to content

Commit 0ca2835

Browse files
committed
fox
1 parent c53e139 commit 0ca2835

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

packages/py-moose-lib/moose_lib/data_models.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -533,10 +533,15 @@ def py_type_to_column_type(t: type, mds: list[Any]) -> Tuple[bool, list[Any], Da
533533
elif get_origin(t) is dict:
534534
args = get_args(t)
535535
if len(args) == 2:
536-
key_optional, _, key_type = py_type_to_column_type(args[0], [])
537-
value_optional, _, value_type = py_type_to_column_type(args[1], [])
538-
# For dict types, we assume keys are required and values match their type
539-
data_type = MapType(key_type=key_type, value_type=value_type)
536+
# Special case: dict[str, Any] should be JSON type (matches TypeScript's Record<string, any>)
537+
# This is useful for storing arbitrary extra fields in a JSON column
538+
if args[0] is str and args[1] is Any:
539+
data_type = "Json"
540+
else:
541+
key_optional, _, key_type = py_type_to_column_type(args[0], [])
542+
value_optional, _, value_type = py_type_to_column_type(args[1], [])
543+
# For dict types, we assume keys are required and values match their type
544+
data_type = MapType(key_type=key_type, value_type=value_type)
540545
else:
541546
raise ValueError(
542547
f"Dict type must have exactly 2 type arguments, got {len(args)}"

0 commit comments

Comments
 (0)