From 9b5ce6c77dc3b464263fcc2fc8e4505ab9bb6cd7 Mon Sep 17 00:00:00 2001 From: Giorgio Basile <4904905+giorgiobasile@users.noreply.github.com> Date: Thu, 12 Dec 2024 11:19:42 +0100 Subject: [PATCH] Fallback to string for UUID columns --- tipg/resources/response.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tipg/resources/response.py b/tipg/resources/response.py index 0640231b..73b4a185 100644 --- a/tipg/resources/response.py +++ b/tipg/resources/response.py @@ -4,6 +4,7 @@ from typing import Any import orjson +from asyncpg.pgproto import pgproto from fastapi.responses import JSONResponse @@ -12,6 +13,8 @@ def default(obj): """Instruct orjson what to do with types it does not natively serialize""" if isinstance(obj, decimal.Decimal): return str(obj) + elif isinstance(obj, pgproto.UUID): + return str(obj) def orjsonDumps(content: Any):