Fix fdb named parameter support: convert :name to positional ?

fdb does not support named parameters (:name + dict). Convert all
:name placeholders to ? and build a positional list from the param
dict in the same order they appear in the query.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-06-25 19:40:57 -05:00
co-authored by Claude Sonnet 4.6
parent c920b45640
commit 7dc8f37c36
+10 -2
View File
@@ -1,3 +1,4 @@
import re
import fdb
import datetime
import decimal
@@ -62,8 +63,15 @@ class FirebirdService:
return False, "No hay conexión activa", []
try:
cur = self.conn.cursor()
if params is not None:
cur.execute(query, params)
if params:
# fdb no soporta :name — convertir a positional ?
param_names = re.findall(r':([a-zA-Z_][a-zA-Z0-9_]*)', query)
if param_names:
positional_sql = re.sub(r':[a-zA-Z_][a-zA-Z0-9_]*', '?', query)
positional_vals = [params[n] for n in param_names]
cur.execute(positional_sql, positional_vals)
else:
cur.execute(query)
else:
cur.execute(query)
columns = [desc[0] for desc in cur.description] if cur.description else []