summaryrefslogtreecommitdiff
path: root/sqlparse/lexer.py
diff options
context:
space:
mode:
authorDarik Gamble <darik.gamble@gmail.com>2015-03-04 10:34:05 -0500
committerDarik Gamble <darik.gamble@gmail.com>2015-03-04 10:34:05 -0500
commitc9dc9c8b79a3e290c28761a786993b02eff705d6 (patch)
tree67d36c7bf222bd66d0aa340faba53271748b4cd9 /sqlparse/lexer.py
parent15b0cb9e75ca378e94b55b7f1ff23108f0899cde (diff)
downloadsqlparse-c9dc9c8b79a3e290c28761a786993b02eff705d6.tar.gz
get rid of tokens.Punctuation.ArrayIndex, add negative lookbehind for sqlite identifiers
Diffstat (limited to 'sqlparse/lexer.py')
-rw-r--r--sqlparse/lexer.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/sqlparse/lexer.py b/sqlparse/lexer.py
index 999eb2c..4707990 100644
--- a/sqlparse/lexer.py
+++ b/sqlparse/lexer.py
@@ -194,8 +194,10 @@ class Lexer(object):
(r"'(''|\\\\|\\'|[^'])*'", tokens.String.Single),
# not a real string literal in ANSI SQL:
(r'(""|".*?[^\\]")', tokens.String.Symbol),
- (r'(?<=[\w\]])(\[[^\]]*?\])', tokens.Punctuation.ArrayIndex),
- (r'(\[[^\]]+\])', tokens.Name),
+ # sqlite names can be escaped with [square brackets]. left bracket
+ # cannot be preceded by word character or a right bracket --
+ # otherwise it's probably an array index
+ (r'(?<![\w\])])(\[[^\]]+\])', tokens.Name),
(r'((LEFT\s+|RIGHT\s+|FULL\s+)?(INNER\s+|OUTER\s+|STRAIGHT\s+)?|(CROSS\s+|NATURAL\s+)?)?JOIN\b', tokens.Keyword),
(r'END(\s+IF|\s+LOOP)?\b', tokens.Keyword),
(r'NOT NULL\b', tokens.Keyword),