Returns the alias for this identifier or ``None``.
(self)
| 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 | |
| 39 | class Token: |
nothing calls this directly
no test coverage detected