From be3b2d73ef118fa5bbf1549e2f9a71baae709cea Mon Sep 17 00:00:00 2001 From: Andi Albrecht Date: Fri, 24 Apr 2009 15:05:23 +0200 Subject: Handle wildcards in identifiers. --- sqlparse/engine/grouping.py | 4 +++- sqlparse/sql.py | 13 ++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'sqlparse') diff --git a/sqlparse/engine/grouping.py b/sqlparse/engine/grouping.py index 3a57496..41e123e 100644 --- a/sqlparse/engine/grouping.py +++ b/sqlparse/engine/grouping.py @@ -102,7 +102,9 @@ def group_case(tlist): def group_identifier(tlist): def _consume_cycle(tl, i): x = itertools.cycle((lambda y: y.match(T.Punctuation, '.'), - lambda y: y.ttype in (T.String.Symbol, T.Name))) + lambda y: y.ttype in (T.String.Symbol, + T.Name, + T.Wildcard))) for t in tl.tokens[i:]: if x.next()(t): yield t diff --git a/sqlparse/sql.py b/sqlparse/sql.py index db9f1c1..3ab93ba 100644 --- a/sqlparse/sql.py +++ b/sqlparse/sql.py @@ -320,7 +320,18 @@ class Identifier(TokenList): def get_real_name(self): """Returns the real name (object name) of this identifier.""" - return self.token_next_by_type(0, T.Name).value + # a.b + dot = self.token_next_match(0, T.Punctuation, '.') + if dot is None: + return self.token_next_by_type(0, T.Name).value + else: + return self.token_next_by_type(self.token_index(dot), + (T.Name, T.Wildcard)).value + + def is_wildcard(self): + """Return ``True`` if this identifier contains a wildcard.""" + token = self.token_next_by_type(0, T.Wildcard) + return token is not None def get_typecast(self): """Returns the typecast or ``None`` of this object as a string.""" -- cgit v1.2.1