MysqlSchemaUtil { String removeCommentsFromDDL(final String ddl) { return ddl .replaceAll("/\\*!(?:\\d{5})?(.*?)\\*/", "$1") .replaceAll("/\\*[^*]*\\*+(?:[^", " ") .replaceAll("\\h+", " ") .replaceAll("^\\s+", ""); }  void executeWithJdbc(
      @NonNull final Handle handle, final String database, @NonNull final String sql); String escapeBackQuote(@NonNull final String name); final Retryer<Void> VOID_RETRYER; final Retryer<List<MysqlColumn>> LIST_COLUMN_RETRYER; final Retryer<List<MysqlTableSchema>> LIST_TABLE_SCHEMA_RETRYER; final Retryer<List<String>> LIST_STRING_RETRYER; }
@Test public void testBlockSQLCommentsRemoval() { String sql_with_block_comments = "CREATEUNIQUE INDEX unique_index\n" + "ON `my_db`.`my_table` (`col1`, `col2`)"; String sql_with_comments_in_multi_lines = "CREATE UNIQUE \n" + "INDEX ON `my_db`.`my_table` (`col1`, `col2`)"; String expected_sql = "CREATE UNIQUE INDEX unique_index\nON `my_db`.`my_table` (`col1`, `col2`)"; String stripped_sql = MysqlSchemaUtil.removeCommentsFromDDL(sql_with_block_comments); assertEquals(expected_sql, stripped_sql); stripped_sql = MysqlSchemaUtil.removeCommentsFromDDL(sql_with_comments_in_multi_lines); expected_sql = "CREATE UNIQUE \nINDEX ON `my_db`.`my_table` (`col1`, `col2`)"; assertEquals(expected_sql, stripped_sql); }
@Test public void testMySQLSpecCommentsRemoval() { String sql_with_mysql_spec_comments = "CREATE TABLE t1(a INT, KEY (a)) "; String sql_with_mysql_spec_comments2 = ""; String expected_sql = "CREATE TABLE t1(a INT, KEY (a)) KEY_BLOCK_SIZE=1024 "; String stripped_sql = MysqlSchemaUtil.removeCommentsFromDDL(sql_with_mysql_spec_comments); assertEquals(expected_sql, stripped_sql); expected_sql = "CREATE TABLE t1(a INT, KEY (a))"; stripped_sql = MysqlSchemaUtil.removeCommentsFromDDL(sql_with_mysql_spec_comments2); assertEquals(expected_sql, stripped_sql); }