Skip to content

Fix SyntaxWarning: invalid escape sequence '\:' #1061

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/sql/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
Loading