summaryrefslogtreecommitdiff
path: root/sqlparse/lexer.py
diff options
context:
space:
mode:
authorAndi Albrecht <albrecht.andi@gmail.com>2015-03-05 11:54:33 +0100
committerAndi Albrecht <albrecht.andi@gmail.com>2015-03-05 11:54:33 +0100
commitbf2616058ada2748bb79fc7c861abb7748ffb89a (patch)
tree712c0352906003c6b4d4148705c28706a7b426a0 /sqlparse/lexer.py
parent15b0cb9e75ca378e94b55b7f1ff23108f0899cde (diff)
parentacdebefd638225eefe438919897ba68e7882504b (diff)
downloadsqlparse-bf2616058ada2748bb79fc7c861abb7748ffb89a.tar.gz
Merge pull request #177 from darikg/brackets
Better square bracket / array index handling
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),