【问题标题】:Parentheses and comma in Liquibase contextLiquibase 上下文中的括号和逗号
【发布时间】:2018-05-08 14:16:21
【问题描述】:

我可以在 liquibase 上下文属性中混合 () 和 , 吗?

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

对我来说很好。但是,如果我使用更紧凑的形式

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

我得到 运行 Liquibase 时出现意外错误:无法解析上下文模式 (c1.

我正在使用 Liquibase 3.5.1。

【问题讨论】:

    标签: liquibase


    【解决方案1】:

    我刚刚对当前源代码进行了 grep 处理,而 ContextExpression 类是该消息的来源。这里是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);
    }
    

    您包含的错误消息说Unexpected error running Liquibase: Cannot parse context pattern (c1.c1 之后有一个句点,这很奇怪,因为您的输入字符串(在此代码块中为expression)中没有句点。

    还有some tests for this class,但我没有看到任何涵盖您的示例的内容。

    【讨论】:

      猜你喜欢
      • 2018-04-14
      • 2015-09-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多