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:
co-authored by
Claude Sonnet 4.6
parent
c920b45640
commit
7dc8f37c36
@@ -1,3 +1,4 @@
|
|||||||
|
import re
|
||||||
import fdb
|
import fdb
|
||||||
import datetime
|
import datetime
|
||||||
import decimal
|
import decimal
|
||||||
@@ -62,8 +63,15 @@ class FirebirdService:
|
|||||||
return False, "No hay conexión activa", []
|
return False, "No hay conexión activa", []
|
||||||
try:
|
try:
|
||||||
cur = self.conn.cursor()
|
cur = self.conn.cursor()
|
||||||
if params is not None:
|
if params:
|
||||||
cur.execute(query, 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:
|
else:
|
||||||
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 []
|
||||||
|
|||||||
Reference in New Issue
Block a user