diff options
author | prudhvi <prudhvi@pocketgems.com> | 2013-09-13 11:34:14 -0700 |
---|---|---|
committer | prudhvi <prudhvi@pocketgems.com> | 2013-09-13 13:12:11 -0700 |
commit | 9574c16bc7418e07e3a21a1c00e4ad5956b799c3 (patch) | |
tree | 5a7f76d66c1ba2d4438fb730816be1e0ceb68007 /sqlparse/engine | |
parent | 3b41501e850f3de9c0ac3c480bf63e73aa20a45d (diff) | |
download | sqlparse-9574c16bc7418e07e3a21a1c00e4ad5956b799c3.tar.gz |
Parenthesis, Functions and Arithmetic Expressions
are valid types to group an identifier
Diffstat (limited to 'sqlparse/engine')
-rw-r--r-- | sqlparse/engine/grouping.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/sqlparse/engine/grouping.py b/sqlparse/engine/grouping.py index 07f9392..4ba90aa 100644 --- a/sqlparse/engine/grouping.py +++ b/sqlparse/engine/grouping.py @@ -148,7 +148,9 @@ def group_identifier(tlist): T.String.Single, T.Name, T.Wildcard, - T.Literal.Number.Integer)))) + T.Literal.Number.Integer, + T.Literal.Number.Float) + or isinstance(y, (sql.Parenthesis, sql.Function))))) for t in tl.tokens[i:]: # Don't take whitespaces into account. if t.ttype is T.Whitespace: @@ -163,8 +165,9 @@ def group_identifier(tlist): # chooses the next token. if two tokens are found then the # first is returned. t1 = tl.token_next_by_type( - i, (T.String.Symbol, T.String.Single, T.Name)) - t2 = tl.token_next_by_instance(i, sql.Function) + i, (T.String.Symbol, T.String.Single, T.Name, T.Literal.Number.Integer, + T.Literal.Number.Float)) + t2 = tl.token_next_by_instance(i, (sql.Function, sql.Parenthesis)) if t1 and t2: i1 = tl.token_index(t1) i2 = tl.token_index(t2) @@ -192,7 +195,9 @@ def group_identifier(tlist): if identifier_tokens and identifier_tokens[-1].ttype is T.Whitespace: identifier_tokens = identifier_tokens[:-1] if not (len(identifier_tokens) == 1 - and isinstance(identifier_tokens[0], sql.Function)): + and (isinstance(identifier_tokens[0], (sql.Function, sql.Parenthesis)) + or identifier_tokens[0].ttype in (T.Literal.Number.Integer, + T.Literal.Number.Float))): group = tlist.group_tokens(sql.Identifier, identifier_tokens) idx = tlist.token_index(group) + 1 else: |