From a409020ad506c5d5e1c99359fdccf6e8d5395742 Mon Sep 17 00:00:00 2001 From: ivan tkachenko Date: Tue, 24 Jun 2025 18:31:02 +0300 Subject: [PATCH] Fix SyntaxWarning: invalid escape sequence '\:' Closes #1060 --- src/sql/parse.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sql/parse.py b/src/sql/parse.py index 16abfd138..661d15a1e 100644 --- a/src/sql/parse.py +++ b/src/sql/parse.py @@ -336,8 +336,8 @@ def magic_args(magic_execute, line, cmd_from, allowed_duplicates=None): def escape_string_literals_with_colon_prefix(query): """ - Given a query, replaces all occurrences of ':variable' with '\:variable' and - ":variable" with "\:variable" so that the query can be passed to sqlalchemy.text + Given a query, replaces all occurrences of ':variable' with '\\:variable' and + ":variable" with "\\:variable" so that the query can be passed to sqlalchemy.text without the literals being interpreted as bind parameters. Also calls escape_string_slicing_with_colon_prefix(). It doesn't replace the occurrences of :variable (without quotes) @@ -366,8 +366,8 @@ def escape_string_literals_with_colon_prefix(query): def escape_string_slicing_notation(query): """ - Given a query, replaces all occurrences of 'example'[x:y] with 'example'[x\:y]. - Escaping the colon using \ ensures correct string slicing behavior rather + Given a query, replaces all occurrences of 'example'[x:y] with 'example'[x\\:y]. + Escaping the colon using \\ ensures correct string slicing behavior rather than being interpreted as a bind parameter. Parameters