Skip to content

Commit 4c9d63a

Browse files
committed
Fix asyncpg.pgproto.pgproto.UUID serialization
1 parent a84a6a6 commit 4c9d63a

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/dstack/_internal/utils/json_utils.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import asyncpg.pgproto.pgproto
12
import orjson
23
from pydantic import BaseModel
34

@@ -8,6 +9,13 @@
89
FREEZEGUN = False
910

1011

12+
ASYNCPG = True
13+
try:
14+
import asyncpg.pgproto.pgproto
15+
except ImportError:
16+
ASYNCPG = False
17+
18+
1119
def orjson_default(obj):
1220
if isinstance(obj, float):
1321
# orjson does not convert float subclasses be default
@@ -16,6 +24,9 @@ def orjson_default(obj):
1624
# Allows calling orjson.dumps() on pydantic models
1725
# (e.g. to return from the API)
1826
return obj.dict()
27+
if ASYNCPG:
28+
if isinstance(obj, asyncpg.pgproto.pgproto.UUID):
29+
return str(obj)
1930
if FREEZEGUN:
2031
if isinstance(obj, FakeDatetime):
2132
return obj.isoformat()

0 commit comments

Comments
 (0)