MCPcopy Index your code
hub / github.com/andialbrecht/sqlparse / get_alias

Method get_alias

sqlparse/sql.py:25–36  ·  view source on GitHub ↗

Returns the alias for this identifier or ``None``.

(self)

Source from the content-addressed store, hash-verified

23 return self._get_first_name(dot_idx, real_name=True)
24
25 def get_alias(self):
26 """Returns the alias for this identifier or ``None``."""
27
28 # "name AS alias"
29 kw_idx, kw = self.token_next_by(m=(T.Keyword, 'AS'))
30 if kw is not None:
31 return self._get_first_name(kw_idx + 1, keywords=True)
32
33 # "name alias" or "complicated column expression alias"
34 _, ws = self.token_next_by(t=T.Whitespace)
35 if len(self.tokens) > 2 and ws is not None:
36 return self._get_first_name(reverse=True)
37
38
39class Token:

Callers

nothing calls this directly

Calls 2

token_next_byMethod · 0.80
_get_first_nameMethod · 0.80

Tested by

no test coverage detected