@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); }
String removeCommentsFromDDL(final String ddl) { return ddl .replaceAll("/\\*!(?:\\d{5})?(.*?)\\*/", "$1") .replaceAll("/\\*[^*]*\\*+(?:[^", " ") .replaceAll("\\h+", " ") .replaceAll("^\\s+", ""); }
MysqlSchemaUtil { String removeCommentsFromDDL(final String ddl) { return ddl .replaceAll("/\\*!(?:\\d{5})?(.*?)\\*/", "$1") .replaceAll("/\\*[^*]*\\*+(?:[^", " ") .replaceAll("\\h+", " ") .replaceAll("^\\s+", ""); } }
MysqlSchemaUtil { String removeCommentsFromDDL(final String ddl) { return ddl .replaceAll("/\\*!(?:\\d{5})?(.*?)\\*/", "$1") .replaceAll("/\\*[^*]*\\*+(?:[^", " ") .replaceAll("\\h+", " ") .replaceAll("^\\s+", ""); }  }
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); }
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; }