diff options
Diffstat (limited to 'sqlglot/tokens.py')
-rw-r--r-- | sqlglot/tokens.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/sqlglot/tokens.py b/sqlglot/tokens.py index e5b44e7..cf2e31f 100644 --- a/sqlglot/tokens.py +++ b/sqlglot/tokens.py @@ -163,6 +163,7 @@ class TokenType(AutoName): CURRENT_ROW = auto() CURRENT_TIME = auto() CURRENT_TIMESTAMP = auto() + CURRENT_USER = auto() DEFAULT = auto() DELETE = auto() DESC = auto() @@ -506,6 +507,7 @@ class Tokenizer(metaclass=_Tokenizer): "CURRENT ROW": TokenType.CURRENT_ROW, "CURRENT_TIME": TokenType.CURRENT_TIME, "CURRENT_TIMESTAMP": TokenType.CURRENT_TIMESTAMP, + "CURRENT_USER": TokenType.CURRENT_USER, "DATABASE": TokenType.DATABASE, "DEFAULT": TokenType.DEFAULT, "DELETE": TokenType.DELETE, @@ -908,7 +910,7 @@ class Tokenizer(metaclass=_Tokenizer): if not word: if self._char in self.SINGLE_TOKENS: - self._add(self.SINGLE_TOKENS[self._char]) # type: ignore + self._add(self.SINGLE_TOKENS[self._char], text=self._char) # type: ignore return self._scan_var() return @@ -921,7 +923,8 @@ class Tokenizer(metaclass=_Tokenizer): return self._advance(size - 1) - self._add(self.KEYWORDS[word.upper()]) + word = word.upper() + self._add(self.KEYWORDS[word], text=word) def _scan_comment(self, comment_start: str) -> bool: if comment_start not in self._COMMENTS: # type: ignore @@ -946,7 +949,7 @@ class Tokenizer(metaclass=_Tokenizer): # Leading comment is attached to the succeeding token, whilst trailing comment to the preceding. # Multiple consecutive comments are preserved by appending them to the current comments list. - if comment_start_line == self._prev_token_line: + if comment_start_line == self._prev_token_line or self._end: self.tokens[-1].comments.extend(self._comments) self._comments = [] self._prev_token_line = self._line |