Skip to content

Commit f777c7b

Browse files
author
Eugene Shershen
committed
implement UUID parameter binding
1 parent e27127d commit f777c7b

File tree

1 file changed

+46
-2
lines changed

1 file changed

+46
-2
lines changed

psqlpy_sqlalchemy/connection.py

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,17 @@ def _convert_named_params_with_casting(
170170
171171
And converts the parameters dict to a list in the correct order.
172172
"""
173+
# Add debugging logging for CI troubleshooting
174+
import logging
175+
176+
logger = logging.getLogger(__name__)
177+
logger.debug(
178+
f"Parameter conversion called - Query: {querystring!r}, "
179+
f"Parameters: {parameters!r}, Parameters type: {type(parameters)}"
180+
)
181+
173182
if parameters is None or not isinstance(parameters, dict):
183+
logger.debug("Parameters is None or not dict, returning as-is")
174184
return querystring, parameters
175185

176186
import re
@@ -182,7 +192,14 @@ def _convert_named_params_with_casting(
182192
# Find all parameter references in the query
183193
matches = list(re.finditer(param_pattern, querystring))
184194

195+
logger.debug(f"Found {len(matches)} parameter matches in query")
196+
for i, match in enumerate(matches):
197+
logger.debug(
198+
f" Match {i + 1}: '{match.group(0)}' -> param='{match.group(1)}', cast='{match.group(2)}'"
199+
)
200+
185201
if not matches:
202+
logger.debug("No parameter matches found, returning as-is")
186203
return querystring, parameters
187204

188205
# Build the conversion mapping and new parameter list
@@ -202,10 +219,27 @@ def _convert_named_params_with_casting(
202219

203220
# Defensive check: ensure all parameters found in query are available
204221
if missing_params:
222+
# Enhanced error message with more debugging information
223+
available_params = list(parameters.keys()) if parameters else []
224+
found_params = [m.group(1) for m in matches]
225+
226+
# Log additional debugging information for CI troubleshooting
227+
import logging
228+
229+
logger = logging.getLogger(__name__)
230+
logger.error(
231+
f"Parameter conversion error - Missing parameters: {missing_params}. "
232+
f"Query: {querystring!r}. "
233+
f"Found in query: {found_params}. "
234+
f"Available in dict: {available_params}. "
235+
f"Parameters dict: {parameters!r}"
236+
)
237+
205238
raise ValueError(
206239
f"Missing parameters in query: {missing_params}. "
207-
f"Query contains parameters {[m.group(1) for m in matches]} "
208-
f"but parameters dict only has {list(parameters.keys())}"
240+
f"Query contains parameters {found_params} "
241+
f"but parameters dict only has {available_params}. "
242+
f"This may indicate a parameter processing issue in the execution pipeline."
209243
)
210244

211245
# Convert the query string by replacing each parameter with its positional equivalent
@@ -269,6 +303,16 @@ def _convert_named_params_with_casting(
269303
f"Converted query: {converted_query}, Original query: {querystring}"
270304
)
271305

306+
# Log final conversion results for debugging
307+
logger.debug(
308+
f"Parameter conversion completed - "
309+
f"Original query: {querystring!r}, "
310+
f"Converted query: {converted_query!r}, "
311+
f"Original params: {parameters!r}, "
312+
f"Converted params: {converted_params!r}, "
313+
f"Parameter order: {param_order}"
314+
)
315+
272316
return converted_query, converted_params
273317

274318
@property

0 commit comments

Comments
 (0)