summaryrefslogtreecommitdiff
path: root/sqlparse
diff options
context:
space:
mode:
authorcasey <casey@cloudera.com>2015-02-26 12:32:46 -0800
committercasey <casey@cloudera.com>2015-02-26 12:32:46 -0800
commite75e35869473832a1eb67772b1adfee2db11b85a (patch)
treead6003130092f9fac951ba29740162cb6931a6d9 /sqlparse
parent77e0789aea8918a2fbbc6f20196cd0bcdecccf52 (diff)
downloadsqlparse-e75e35869473832a1eb67772b1adfee2db11b85a.tar.gz
Recognize escaped backslashes within strings
Previously if a single quoted string ended with an escaped backslash, parsing would not consider the string to be terminated.
Diffstat (limited to 'sqlparse')
-rw-r--r--sqlparse/lexer.py3
1 files changed, 1 insertions, 2 deletions
diff --git a/sqlparse/lexer.py b/sqlparse/lexer.py
index 3e9a1a6..5282ad3 100644
--- a/sqlparse/lexer.py
+++ b/sqlparse/lexer.py
@@ -191,8 +191,7 @@ class Lexer(object):
(r'[-]?[0-9]*(\.[0-9]+)?[eE][-]?[0-9]+', tokens.Number.Float),
(r'[-]?[0-9]*\.[0-9]+', tokens.Number.Float),
(r'[-]?[0-9]+', tokens.Number.Integer),
- # TODO: Backslash escapes?
- (r"'(''|\\'|[^'])*'", tokens.String.Single),
+ (r"'(''|\\\\|\\'|[^'])*'", tokens.String.Single),
# not a real string literal in ANSI SQL:
(r'(""|".*?[^\\]")', tokens.String.Symbol),
(r'(?<=[\w\]])(\[[^\]]*?\])', tokens.Punctuation.ArrayIndex),