1
votes

Can I mix () and , in a liquibase context attribute?

<changeSet id="xxx" author="mhz" context="(c1 or c2 or c3 or c4) and blackbox-test" >

works fine for me. However, if I use the more compact form

<changeSet id="xxx" author="mhz" context="(c1,c2,c3,c4) and blackbox-test" >

I get Unexpected error running Liquibase: Cannot parse context pattern (c1.

I am using Liquibase 3.5.1.

1

1 Answers

0
votes

I just grep'ed the current source code and the class ContextExpression is where this message is coming from. Here is the block of code:

while (expression.contains("(")) {
    Pattern pattern = Pattern.compile("(.*?)\\((.*?)\\)(.*)");
    Matcher matcher = pattern.matcher(expression);
    if (!matcher.matches()) {
        throw new UnexpectedLiquibaseException("Cannot parse context pattern "+expression);
    }
    String parenExpression = matcher.group(2);

    parenExpression = ":"+String.valueOf(matches(parenExpression, runtimeContexts)).toUpperCase();

    expression = matcher.group(1)+" "+parenExpression+" "+matcher.group(3);
}

The error message you included said Unexpected error running Liquibase: Cannot parse context pattern (c1. with a period after c1, which is strange because your inpuit string (which is expression in this block of code) does not have a period in it.

There are some tests for this class also, but I don't see anything that covers your example.