MCPcopy
hub / github.com/andialbrecht/sqlparse / _get_first_name

Method _get_first_name

sqlparse/sql.py:385–400  ·  view source on GitHub ↗

Returns the name of the first token with a name

(self, idx=None, reverse=False, keywords=False,
                        real_name=False)

Source from the content-addressed store, hash-verified

383 return remove_quotes(prev_.value) if prev_ is not None else None
384
385 def _get_first_name(self, idx=None, reverse=False, keywords=False,
386 real_name=False):
387 """Returns the name of the first token with a name"""
388
389 tokens = self.tokens[idx:] if idx else self.tokens
390 tokens = reversed(tokens) if reverse else tokens
391 types = [T.Name, T.Wildcard, T.String.Symbol]
392
393 if keywords:
394 types.append(T.Keyword)
395
396 for token in tokens:
397 if token.ttype in types:
398 return remove_quotes(token.value)
399 elif isinstance(token, (Identifier, Function)):
400 return token.get_real_name() if real_name else token.get_name()
401
402
403class Statement(TokenList):

Callers 2

get_real_nameMethod · 0.80
get_aliasMethod · 0.80

Calls 3

remove_quotesFunction · 0.90
get_nameMethod · 0.80
get_real_nameMethod · 0.45

Tested by

no test coverage detected