Parameters set in included file are no longer set in 3.2.0

Description

I've been trying to port my Spatial extension to Liquibase 3.2.0 but found that my integration tests were failing. I think I've narrowed this down to change log parameters being set in an included file are no longer set in my change log under test.

The test checks the state of the database (Derby, H2, etc) using preconditions with parameters. Unfortunately the parameters are not expanded so I get SQL validation errors back from the database. I verified that the problem is not limited to just the sqlCheck precondition but also affects the "sql" change. I've tested this both from Liquibase on the command-line and my test code with the same errors so I'm reasonably assured that it's not something with my test setup.

Here are the pertinent portions of my change logs:

create-table-index-drop-index-table.xml

<?xml version="1.0" encoding="UTF-8"?> <databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:spatial="http://www.liquibase.org/xml/ns/dbchangelog-ext/liquibase-spatial" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd http://www.liquibase.org/xml/ns/dbchangelog-ext/liquibase-spatial http://lonnyj.github.io/liquibase-spatial/liquibase-spatial.xsd"> <include file="properties.xml"/> <changeSet id="Verify geometry_columns inserted" author="test" dbms="derby, h2, postgresql"> <preConditions> <sqlCheck expectedResult="1"> SELECT count(*) FROM geometry_columns WHERE f_table_schema = ${current_schema_sql} AND upper(f_table_name) = 'TEST' AND upper(f_geometry_column) = 'GEOM' </sqlCheck> </preConditions> </changeSet>

properties.xml

<?xml version="1.0" encoding="UTF-8"?> <databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd"> <!-- The SQL that returns the current schema. --> <property name="current_schema_sql" value="CURRENT SCHEMA" dbms="derby" /> <property name="current_schema_sql" value="schema()" dbms="h2, mysql" /> <property name="current_schema_sql" value="(SELECT sys_context('USERENV', 'CURRENT_SCHEMA') FROM dual)" dbms="oracle" /> <property name="current_schema_sql" value="current_schema" dbms="postgresql" /> </databaseChangeLog>

When I run my test, I receive this error:

liquibase.exception.MigrationFailedException: Migration failed for change set create-table-index-drop-index-table.xml::Verify geometry_columns inserted::test: Reason: create-table-index-drop-index-table.xml : liquibase.precondition.core.SqlPrecondition@43ccb601 : Syntax error in SQL statement "SELECT COUNT(*) FROM GEOMETRY_COLUMNS WHERE F_TABLE_SCHEMA = $ CURRENT_SCHEMA_SQL[*] AND UPPER(F_TABLE_NAME) = 'TEST' AND UPPER(F_GEOMETRY_COLUMN) = 'GEOM' "; SQL statement: SELECT count(*) FROM geometry_columns WHERE f_table_schema = $ current_schema_sql AND upper(f_table_name) = 'TEST' AND upper(f_geometry_column) = 'GEOM' [42000-177]

Notice that the SQL includes "$ current_schema_sql" instead of "schema()" as defined in properties.xml. When I move that property declaration to create-table-index-drop-table.xml, the test passes.

My test change logs can be found here if you'd like to see the complete versions.

Environment

Windows 7
Java 7u55
Derby and H2

Activity

Show:

Nathan Voxland October 31, 2014 at 3:44 PM

Fixed in 3.3.0. Took enough of a change in the parsing that I didn't want to introduce it in a patch release.

Fixed

Details

Reporter

Fix versions

Affects versions

Priority

Created July 24, 2014 at 5:43 AM
Updated October 31, 2014 at 3:44 PM
Resolved October 31, 2014 at 3:44 PM