Skip to content

Commit 7999d98

Browse files
committed
added JSON serialisation for timedeltas
1 parent 8663485 commit 7999d98

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

piccolo/query/base.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from __future__ import annotations
2+
import datetime
23
import itertools
34
from time import time
45
import typing as t
@@ -26,7 +27,9 @@ def default(obj):
2627
"""
2728
Used for handling edge cases which orjson can't serialise out of the box.
2829
"""
29-
if isinstance(obj, UUID):
30+
# This is the asyncpg UUID, not the builtin Python UUID, which orjon can
31+
# serialise out of the box.
32+
if isinstance(obj, (UUID, datetime.timedelta)):
3033
return str(obj)
3134
raise TypeError
3235

0 commit comments

Comments
 (0)