Skip to content

Commit 5bbebcb

Browse files
authored
Serialize custom UUIDs to JSON (#1266)
1 parent 8329675 commit 5bbebcb

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Releases prior to 7.0 has been removed from this file to declutter search result
1818
- config: Fixed `config export` command crash when `advanced.reindex` section is present in config.
1919
- config: Do not trigger `config_modified` reindexing when datasource URLs are updated.
2020
- datasources: Do not run datasources not linked to any index and without `realtime` flag set.
21+
- models: Fixed serializing UUIDs in `JSONField`.
2122
- substrate: Fixed loading type registries when specified in config.
2223
- substrate: Fixed processing several vector types.
2324

src/dipdup/utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from typing import Any
1818
from typing import TextIO
1919
from typing import TypeVar
20+
from uuid import UUID
2021

2122
import orjson
2223
from humps import main as humps
@@ -229,6 +230,9 @@ def parse_object(
229230
def _default_for_decimals(obj: Any) -> Any:
230231
if isinstance(obj, Decimal):
231232
return str(obj)
233+
# NOTE: although UUID is serializable by orjson, asyncpg UUID type is not
234+
if isinstance(obj, UUID):
235+
return str(obj)
232236
raise TypeError
233237

234238

0 commit comments

Comments
 (0)