Fix: serializar tipos Firebird no-JSON (date, datetime, Decimal) en execute_query
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
408ea50d21
commit
c663df006b
@@ -1,7 +1,17 @@
|
|||||||
import fdb
|
import fdb
|
||||||
|
import datetime
|
||||||
|
import decimal
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
|
|
||||||
|
def _safe(v):
|
||||||
|
if isinstance(v, (datetime.date, datetime.datetime)):
|
||||||
|
return v.isoformat()
|
||||||
|
if isinstance(v, decimal.Decimal):
|
||||||
|
return float(v)
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class FirebirdService:
|
class FirebirdService:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.conn = None
|
self.conn = None
|
||||||
@@ -50,7 +60,7 @@ class FirebirdService:
|
|||||||
cur.execute(query)
|
cur.execute(query)
|
||||||
columns = [desc[0] for desc in cur.description] if cur.description else []
|
columns = [desc[0] for desc in cur.description] if cur.description else []
|
||||||
rows = cur.fetchall()
|
rows = cur.fetchall()
|
||||||
return True, "", [dict(zip(columns, row)) for row in rows]
|
return True, "", [{c: _safe(v) for c, v in zip(columns, row)} for row in rows]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return False, str(e), []
|
return False, str(e), []
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user