def tokens2sql(token: Token, query: 'query_module.BaseQuery' ) -> Iterator[all_token_types]: from .functions import SQLFunc if isinstance(token, Identifier): # Bug fix for sql parse if isinstance(token[0], Parenthesis): try: int(token[0][1].value) except ValueError: yield SQLIdentifier(token[0][1], query) else: yield SQLConstIdentifier(token, query) elif isinstance(token[0], Function): yield SQLFunc.token2sql(token, query) else: yield SQLIdentifier(token, query) elif isinstance(token, Function): yield SQLFunc.token2sql(token, query) elif isinstance(token, Comparison): yield SQLComparison(token, query) elif isinstance(token, IdentifierList): for tok in token.get_identifiers(): yield from SQLToken.tokens2sql(tok, query) elif isinstance(token, Parenthesis): yield SQLPlaceholder(token, query) else: raise SQLDecodeError(f'Unsupported: {token.value}')
def handle_select(self, idx: int, next_token: Token) -> Tuple[Columns, int]: tokens: List[Token] = ( next_token.get_identifiers() if isinstance(next_token, IdentifierList) else [next_token] ) columns = self._extract_columns(tokens) return columns, idx