Skip to content


Two small changes: a typo, and a big performance boost for formatted SQL input. #42

merged 2 commits into from

2 participants


Corrected one small typo in help text;
also inverted the sense of the regular expressions that strip comments, improving performance quite a bit in my tests.

@nvoxland nvoxland merged commit 8731bc5 into liquibase:master


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
2  liquibase-core/src/main/java/liquibase/integration/commandline/
@@ -415,7 +415,7 @@ protected void printHelp(PrintStream stream) {
stream.println(" updateSQL Writes SQL to update database to current");
stream.println(" version to STDOUT");
stream.println(" updateCount <num> Applies next NUM changes to the database");
- stream.println(" updateSQL <num> Writes SQL to apply next NUM changes");
+ stream.println(" updateCountSQL <num> Writes SQL to apply next NUM changes");
stream.println(" to the database");
stream.println(" rollback <tag> Rolls back the database to the the state is was");
stream.println(" when the tag was applied");
8 liquibase-core/src/main/java/liquibase/util/
@@ -10,6 +10,9 @@
* Various utility methods for working with strings.
public class StringUtils {
+ private static final Pattern commentPattern = Pattern.compile("/\\*.*?\\*/", Pattern.DOTALL);
+ private static final Pattern dashPattern = Pattern.compile("\\-\\-.*$", Pattern.MULTILINE);
public static String trimToEmpty(String string) {
if (string == null) {
return "";
@@ -78,9 +81,8 @@ public static String trimToNull(String string) {
* @return The String without the comments in
public static String stripComments(String multiLineSQL) {
- String strippedSingleLines = Pattern.compile("(.*?)\\s*\\-\\-.*\n").matcher(multiLineSQL).replaceAll("$1\n");
- strippedSingleLines = Pattern.compile("(.*?)\\s*\\-\\-.*$").matcher(strippedSingleLines).replaceAll("$1\n");
- return Pattern.compile("/\\*.*?\\*/", Pattern.DOTALL).matcher(strippedSingleLines).replaceAll("").trim();
+ String strippedDashDash = dashPattern.matcher(multiLineSQL).replaceAll("");
+ return commentPattern.matcher(strippedDashDash).replaceAll("").trim();
public static String join(String[] array, String delimiter) {
Something went wrong with that request. Please try again.