diff options
| author | Darik Gamble <darik.gamble@gmail.com> | 2015-03-04 10:34:05 -0500 |
|---|---|---|
| committer | Darik Gamble <darik.gamble@gmail.com> | 2015-03-04 10:34:05 -0500 |
| commit | c9dc9c8b79a3e290c28761a786993b02eff705d6 (patch) | |
| tree | 67d36c7bf222bd66d0aa340faba53271748b4cd9 /sqlparse | |
| parent | 15b0cb9e75ca378e94b55b7f1ff23108f0899cde (diff) | |
| download | sqlparse-c9dc9c8b79a3e290c28761a786993b02eff705d6.tar.gz | |
get rid of tokens.Punctuation.ArrayIndex, add negative lookbehind for sqlite identifiers
Diffstat (limited to 'sqlparse')
| -rw-r--r-- | sqlparse/lexer.py | 6 | ||||
| -rw-r--r-- | sqlparse/tokens.py | 1 |
2 files changed, 4 insertions, 3 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), diff --git a/sqlparse/tokens.py b/sqlparse/tokens.py index 014984b..01a9b89 100644 --- a/sqlparse/tokens.py +++ b/sqlparse/tokens.py @@ -57,7 +57,6 @@ Literal = Token.Literal String = Literal.String Number = Literal.Number Punctuation = Token.Punctuation -ArrayIndex = Punctuation.ArrayIndex Operator = Token.Operator Comparison = Operator.Comparison Wildcard = Token.Wildcard |
