summaryrefslogtreecommitdiff
path: root/sqlparse
diff options
context:
space:
mode:
authorAndi Albrecht <albrecht.andi@gmail.com>2013-09-15 00:07:43 -0700
committerAndi Albrecht <albrecht.andi@gmail.com>2013-09-15 00:07:43 -0700
commit8d703748577844f94dd99383747031be1e3545f9 (patch)
tree5a7f76d66c1ba2d4438fb730816be1e0ceb68007 /sqlparse
parent3b41501e850f3de9c0ac3c480bf63e73aa20a45d (diff)
parent9574c16bc7418e07e3a21a1c00e4ad5956b799c3 (diff)
downloadsqlparse-8d703748577844f94dd99383747031be1e3545f9.tar.gz
Merge pull request #110 from pvatala/master
Parenthesis, Functions and Arithmetic Expressions in Identifiers
Diffstat (limited to 'sqlparse')
-rw-r--r--sqlparse/engine/grouping.py13
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: