X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=scripts%2Fmysql2sql;h=98c5f10e6eeee216120facaa3b53250ab47decdb;hb=ba77a72dda60df0d20f8493559382b8f756c61ba;hp=3809c1b29ea99675afb817ca98c97aa11e339dc8;hpb=447c2ab10de0e28b7d6ecc95c3c2aaf0efddebd3;p=sqlconvert.git diff --git a/scripts/mysql2sql b/scripts/mysql2sql index 3809c1b..98c5f10 100755 --- a/scripts/mysql2sql +++ b/scripts/mysql2sql @@ -7,8 +7,9 @@ import os import sys from sqlparse.compat import text_type -from mysql2sql.print_tokens import print_tokens -from mysql2sql.process_tokens import requote_names, StatementGrouper +from sqlconvert.print_tokens import print_tokens +from sqlconvert.process_mysql import is_directive_statement, process_statement +from sqlconvert.process_tokens import is_newline_statement, StatementGrouper from m_lib.defenc import default_encoding from m_lib.pbar.tty_pbar import ttyProgressBar @@ -38,6 +39,7 @@ def main(infile, encoding, outfile, output_encoding, use_pbar): cur_pos = 0 grouper = StatementGrouper(encoding=encoding) + got_directive = False for line in infile: if use_pbar: if isinstance(line, text_type): @@ -48,7 +50,14 @@ def main(infile, encoding, outfile, output_encoding, use_pbar): grouper.process_line(line) if grouper.statements: for statement in grouper.get_statements(): - requote_names(statement) + if got_directive and is_newline_statement(statement): + # Condense a sequence of newlines after a /*! directive */; + got_directive = False + continue + got_directive = is_directive_statement(statement) + if got_directive: + continue + process_statement(statement) print_tokens(statement, outfile=outfile, encoding=output_encoding) tokens = grouper.close()