fix: convert Decimal to float in API responses instead of string — fixes positions page crash

This commit is contained in:
Celes Renata
2026-04-16 15:25:40 +00:00
parent 354c3d484a
commit 9a8d36068a
+7
View File
@@ -82,10 +82,17 @@ app.add_middleware(TraceMiddleware)
def _row_to_dict(row: asyncpg.Record) -> dict[str, Any]:
"""Convert an asyncpg Record to a JSON-safe dict."""
from decimal import Decimal
from uuid import UUID
d: dict[str, Any] = {}
for key, val in dict(row).items():
if isinstance(val, datetime):
d[key] = val.isoformat()
elif isinstance(val, Decimal):
d[key] = float(val)
elif isinstance(val, UUID):
d[key] = str(val)
elif hasattr(val, "__str__") and not isinstance(val, (str, int, float, bool, list, dict, type(None))):
d[key] = str(val)
else: