Search code examples
xmloracle-databaseliquibasehsqldb

Liquibase boolean for Oracle and HSQLDB


I need to insert a new row inside both Oracle (for prod) and HSQLDB (for tests) with only one <insert>, but the boolean is what makes the problem - Oracle expects 1, HSQLDB expects true.

Here is how I do it right now, but is it possible to remove the dbms and do it for both DBs with the same <insert>

    <insert dbms="oracle" tableName="MY_TABLE">
        <column name="ID" valueComputed="MY_TABLE_ID_SEQ.NEXTVAL"/>
        <column name="NAME" value="JOHN DOE"/>
        <column name="VISIBLE" value="1"/>
    </insert>
    <insert dbms="hsqldb" tableName="MY_TABLE">
        <column name="ID" valueComputed="MY_TABLE_ID_SEQ.NEXTVAL"/>
        <column name="NAME" value="JOHN DOE"/>
        <column name="VISIBLE" value="true"/>
    </insert>

Solution

  • Use valueBoolean. For example:

        <insert dbms="hsqldb" tableName="MY_TABLE">
            <column name="ID" valueComputed="MY_TABLE_ID_SEQ.NEXTVAL"/>
            <column name="NAME" value="JOHN DOE"/>
            <column name="VISIBLE" valueBoolean="true"/>
        </insert>
    

    That will let liquibase know that the "true" string isn't the string to pass, but a boolean value that should be converted to whatever the target database uses for boolean values.