X-Git-Url: https://git.phdru.name/?p=sqlconvert.git;a=blobdiff_plain;f=sqlconvert%2Fprocess_mysql.py;h=ad4d422b4c13fa0ca2f1821009038b0e512c9214;hp=fad7e4cc291a04241834557bbb90aa4c36283e67;hb=HEAD;hpb=b72239847f13152061182973ea573dd2e835a89e diff --git a/sqlconvert/process_mysql.py b/sqlconvert/process_mysql.py index fad7e4c..c89d6d1 100644 --- a/sqlconvert/process_mysql.py +++ b/sqlconvert/process_mysql.py @@ -1,6 +1,6 @@ from sqlparse.sql import Comment, Function, Identifier, Parenthesis, \ - Statement, Token + Statement, Token, Values from sqlparse import tokens as T from .process_tokens import escape_strings, is_comment_or_space @@ -29,7 +29,7 @@ def is_directive_statement(statement): def remove_directive_tokens(statement): - """Remove /\*! directives \*/ from the first-level""" + """Remove /*! directives */ from the first-level""" new_tokens = [] for token in statement.tokens: if _is_directive_token(token): @@ -110,6 +110,14 @@ def split_ext_insert(statement): expected = 'VALUES' continue elif expected == 'VALUES': + if isinstance(token, Values): + for subtoken in token.tokens: + if isinstance(subtoken, Parenthesis): + values_tokens.append(subtoken) + insert_tokens.append(Token(T.Keyword, 'VALUES')) + insert_tokens.append(Token(T.Whitespace, ' ')) + expected = 'VALUES_OR_SEMICOLON' + continue if (token.ttype is T.Keyword) and (token.normalized == 'VALUES'): insert_tokens.append(token) expected = 'VALUES_OR_SEMICOLON'