X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=mysql2sql%2Fprocess_tokens.py;h=2e39a2a7d8a4677de1052fa64639c088beaa579e;hb=b2d8bf8c3a4e4a28d76c2c5bd9492095b14c0db7;hp=c395b37df0cd94bb1cb9b09df2f4b0fd21cd3583;hpb=3289238688d9c3dfefccf143d21f6c406faad9e4;p=sqlconvert.git diff --git a/mysql2sql/process_tokens.py b/mysql2sql/process_tokens.py index c395b37..2e39a2a 100644 --- a/mysql2sql/process_tokens.py +++ b/mysql2sql/process_tokens.py @@ -1,6 +1,6 @@ from sqlparse.sql import TokenList -from sqlparse.tokens import Name +from sqlparse.tokens import Name, Error def requote_names(token_list): @@ -8,11 +8,22 @@ def requote_names(token_list): for token in token_list: if isinstance(token, TokenList): requote_names(token) - else: - if token.ttype is Name: - value = token.value - if (value[0] == "`") and (value[-1] == "`"): - value = value[1:-1] - token.normalized = token.value = value - if not value.islower(): - token.normalized = token.value = '"%s"' % value + elif token.ttype is Name: + value = token.value + if (value[0] == "`") and (value[-1] == "`"): + value = value[1:-1] + if value.islower(): + 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: + if isinstance(token, TokenList): + if find_error(token): + return True + elif token.ttype is Error: + return True + return False