X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=mysql2sql%2Fprocess_tokens.py;h=ac9930eb81963b1e0c376ff67af035aaaca37679;hb=c3477caa7a2663decd4d363dade4827fc37e18ea;hp=2e39a2a7d8a4677de1052fa64639c088beaa579e;hpb=c86449d39cde438e153055e0f7731f0d15b62964;p=sqlconvert.git diff --git a/mysql2sql/process_tokens.py b/mysql2sql/process_tokens.py index 2e39a2a..ac9930e 100644 --- a/mysql2sql/process_tokens.py +++ b/mysql2sql/process_tokens.py @@ -5,10 +5,8 @@ from sqlparse.tokens import Name, Error def requote_names(token_list): """Remove backticks, quote non-lowercase identifiers""" - for token in token_list: - if isinstance(token, TokenList): - requote_names(token) - elif token.ttype is Name: + for token in token_list.flatten(): + if token.ttype is Name: value = token.value if (value[0] == "`") and (value[-1] == "`"): value = value[1:-1] @@ -20,10 +18,7 @@ def requote_names(token_list): def find_error(token_list): """Find an error""" - for token in token_list: - if isinstance(token, TokenList): - if find_error(token): - return True - elif token.ttype is Error: + for token in token_list.flatten(): + if token.ttype is Error: return True return False