Skip to content

Commit 07630b5

Browse files
committed
fix invalid escaping of special characters for lookup
1 parent 5b4fb86 commit 07630b5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

sql_server/pyodbc/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
124124
#
125125
# Note: we use str.format() here for readability as '%' is used as a wildcard for
126126
# the LIKE operator.
127-
pattern_esc = r"REPLACE(REPLACE(REPLACE({}, '\', '\\'), '%%', '\%%'), '_', '\_')"
127+
pattern_esc = r"REPLACE(REPLACE(REPLACE({}, '\', '[\]'), '%%', '[%%]'), '_', '[_]')"
128128
pattern_ops = {
129129
'contains': "LIKE '%%' + {} + '%%'",
130130
'icontains': "LIKE '%%' + UPPER({}) + '%%'",

0 commit comments

Comments
 (0)