X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;ds=sidebyside;f=mysql2sql%2Fprocess_tokens.py;h=ac9930eb81963b1e0c376ff67af035aaaca37679;hb=7d813bbd88d3d206cadf5904a538a8c2db6aad0c;hp=70dadb23bf6080b7764154e8ef3356763e552e37;hpb=5654b305081bc195027ce00302b38af1fb0e249b;p=sqlconvert.git diff --git a/mysql2sql/process_tokens.py b/mysql2sql/process_tokens.py index 70dadb2..ac9930e 100644 --- a/mysql2sql/process_tokens.py +++ b/mysql2sql/process_tokens.py @@ -1,14 +1,12 @@ from sqlparse.sql import TokenList -from sqlparse.tokens import Name +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] @@ -16,3 +14,11 @@ def requote_names(token_list): token.normalized = token.value = value else: token.normalized = token.value = '"%s"' % value + + +def find_error(token_list): + """Find an error""" + for token in token_list.flatten(): + if token.ttype is Error: + return True + return False