Skip to content

Commit e27127d

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

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

psqlpy_sqlalchemy/connection.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,11 +250,15 @@ def _convert_named_params_with_casting(
250250
# Real parameters should not be preceded by a positional parameter like $1, $2, etc.
251251
start_pos = match.start()
252252
if start_pos > 0:
253-
# Look at the characters before the match
253+
# Look at the characters before the match to see if this is casting syntax
254+
# For casting syntax like $1::UUID, we need to check if preceded by $N:
254255
preceding_text = converted_query[
255-
max(0, start_pos - 3) : start_pos
256+
max(0, start_pos - 4) : start_pos
256257
]
257-
# If preceded by $N, this is likely casting syntax, not a parameter
258+
# If preceded by $N: (positional parameter followed by colon), this is casting syntax
259+
if re.search(r"\$\d+:$", preceding_text):
260+
continue
261+
# Also check the older pattern for backward compatibility
258262
if re.search(r"\$\d+$", preceding_text):
259263
continue
260264
remaining_matches.append(full_match)

0 commit comments

Comments
 (0)