Skip to content

Commit

Permalink
serialize dicts better
Browse files Browse the repository at this point in the history
  • Loading branch information
CamDavidsonPilon committed Oct 17, 2024
1 parent cf7e9c3 commit dc97f10
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pioreactor/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from typing import TYPE_CHECKING

from diskcache import Cache # type: ignore
from msgspec.json import encode as dumps

from pioreactor import structs
from pioreactor import types as pt
Expand Down Expand Up @@ -625,7 +626,12 @@ def upsert_setting(self, job_id: JobMetadataKey, setting: str, value: Any) -> No
ON CONFLICT (setting, job_id) DO
UPDATE SET value = :value;
"""
self.cursor.execute(update_query, {"setting": setting, "value": str(value), "job_id": job_id})
if isinstance(value, dict):
value = dumps(value)
else:
value = str(value)

self.cursor.execute(update_query, {"setting": setting, "value": value, "job_id": job_id})

self.conn.commit()
return
Expand Down

0 comments on commit dc97f10

Please sign in to comment.