コード例 #1
0
ファイル: parser.py プロジェクト: macbre/sql-metadata
 def _handle_with_name_save(token: SQLToken, with_names: List[str]) -> None:
     if token.is_right_parenthesis:
         # inside columns of with statement
         # like: with (col1, col2) as (subquery)
         token.is_with_columns_end = True
         token.is_nested_function_end = False
         start_token = token.find_nearest_token("(")
         start_token.is_with_columns_start = True
         start_token.is_nested_function_start = False
         prev_token = start_token.previous_token
         prev_token.token_type = TokenType.WITH_NAME
         with_names.append(prev_token.value)
     else:
         token.token_type = TokenType.WITH_NAME
         with_names.append(token.value)
コード例 #2
0
 def _determine_closing_parenthesis_type(self, token: SQLToken):
     """
     Determines the type of right parenthesis in query
     """
     last_open_parenthesis = self._open_parentheses.pop(-1)
     if last_open_parenthesis.is_subquery_start:
         token.is_subquery_end = True
         self._subquery_level -= 1
     elif last_open_parenthesis.is_column_definition_start:
         token.is_column_definition_end = True
     elif last_open_parenthesis.is_with_query_start:
         token.is_with_query_end = True
     else:
         token.is_nested_function_end = True
         self._nested_level -= 1
         if self._nested_level == 0:
             self._is_in_nested_function = False