Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properties are not being substituted #4129

Closed
1 of 2 tasks
joserebelo opened this issue Apr 13, 2023 · 6 comments · Fixed by #4204
Closed
1 of 2 tasks

Properties are not being substituted #4129

joserebelo opened this issue Apr 13, 2023 · 6 comments · Fixed by #4204

Comments

@joserebelo
Copy link
Contributor

joserebelo commented Apr 13, 2023

Search first

  • I searched and no similar issues were found

Description

Properties are not being substituted when used on changes using the ${parameter} format - they get passed to the changes as the literal string "${parameter}".

git bisect tracked the issue to 6f8a113

Steps To Reproduce

Set a parameter on the defaults file:

parameter.a_parameter=asd

Use the parameter on a change:

<changeSet author="joserebelo" id="test.change">
    <createTable tableName="${a_parameter}">
        <column name="user_id" type="VARCHAR(40)"/>
    </createTable>
</changeSet>

Expected/Desired Behavior

It was expected that a table with the name "asd" would have been created. However, a table with the literal name "${a_parameter}" gets created.

The same issue applies to args in the executeCommand change and params on customChanges.

Liquibase Version

4.21.0

Database Vendor & Version

PostgreSQL 9.6

Liquibase Integration

cli

Liquibase Extensions

No response

OS and/or Infrastructure Type/Provider

No response

Additional Context

No response

Are you willing to submit a PR?

  • I'm willing to submit a PR (Thank you!)
@joserebelo joserebelo changed the title Parameters are not being rendered Propertires are not being substituted Apr 13, 2023
@joserebelo joserebelo changed the title Propertires are not being substituted Properties are not being substituted Apr 13, 2023
@astiob
Copy link

astiob commented Apr 17, 2023

Came here while debugging the same issue. Some more info:

Works when specifying properties on the command line as -Dname=value. Fails when specifying them in the defaults file (liquibase.properties) as parameter.name=value.

The failure affects both the SQL generated (as evidenced by liquibase update-sql run against a blank database/schema) and the changeset checksum (as evidenced by the failures we’re getting from update and by manual liquibase calculate-checksum).

@gallipi
Copy link

gallipi commented Apr 18, 2023

Version 4.21.1 is also affected.
Database: Oracle 19c

Liquibase throws the exception Oracle non supported sql92 token when trying to parse the property.

@alexandre-cartapanis
Copy link

alexandre-cartapanis commented Apr 19, 2023

Same with 4.21.1 and postgresql 14, parameters are not substituted when coming from liquibase.properties with a sql generated and an update command.

Working after rollback to 4.20.0.

@nvoxland
Copy link
Contributor

It's only when you are setting properties from the liquibase.properties file, correct? Or are there other ways anyone is setting them and it's also not working?

@alexandre-cartapanis
Copy link

alexandre-cartapanis commented Apr 20, 2023

I haven't tested all the other methods, I can only say that it works when setting the property via spring-boot with spring.liquibase.parameters.*.

@XDelphiGrl
Copy link
Contributor

I validated the fix for this issue using a changelog that has changesets that use parameters defined in the changelog, parameters defined in the liquibase.properties file and a table that uses a combination of changelog and liquibase.properties parameters. I tested using the CLI against a Postgres 12.6; the Liquibase build is https://github.com/liquibase/liquibase/actions/runs/4874060226.

In all cases, the correct substitution was executed using the fix build.

image

The Changelog (liquibase.properties values listed in comment)

<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"  
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"  
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd 
http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd
http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-latest.xsd">

<!-- Properties and Preconditions --> 
    <property  name="clob.type"    value="clob"  dbms="oracle,postgresql"/>  
    <property  name="clob.type"    value="longtext"  dbms="mysql"/>
	<property  name="clob.type2"   value="foo"  dbms="postgresql"/>
    <property  name="table.name"   value="cltable"/>
	<property  name="column1.name" value="clcol1"/>
	<property  name="column2.name" value="clcol2"/>
	
<!-- ====================================================== -->
<!-- CHANGESETS THAT SUCCESSFULLY DEPLOY                    -->
<!-- ====================================================== -->

<!-- SIMPLE TABLE (No Substitution) -->
	<changeSet author="erz"  id="1::createTable-success" contextFilter="ctx,ctx2" labels="tblsuccess,anotherlabel">
		<comment>Comment for 1::createTable-success</comment>
		<createTable tableName="table_1">
            <column name="name" type="CHAR(20)"/>
        </createTable>
	</changeSet>

<!-- CHANGELOG PROPERTY SUBSTITUTION -->
<!-- Substitution properties defined in changelog -->
    <changeSet author="erz" id="2::substitution-changelog"  dbms="postgresql">  
         <createTable  tableName="${table.name}">  
             <column  name="id"  type="int"/>  
             <column  name="${column1.name}"  type="${clob.type}"/>  
             <column  name="${column2.name}"  type="int"/>  
         </createTable>  
    </changeSet>

<!-- Substitution properties defined in liquibase.properties file. 
parameter.table_name: lbproptable
parameter.table_name2: clandlbproptable
parameter.clob_type: clob
parameter.column1_name: lbpropcol1
parameter.column2_name: lbpropcol2
-->
    <changeSet author="erz" id="2::substitution-properties"  dbms="postgresql">  
         <createTable  tableName="${table_name}">  
             <column  name="id"  type="int"/>  
             <column  name="${column1_name}"  type="${clob_type}"/>  
             <column  name="${column2_name}"  type="int"/>  
         </createTable>  
    </changeSet>

<!-- Mix of changelog and properties file substitution -->	
    <changeSet author="erz" id="2::substitution-mixed"  dbms="postgresql">  
         <createTable  tableName="${table_name2}">  
             <column  name="id"  type="int"/>  
             <column  name="${column1.name}"  type="${clob_type}"/>  
             <column  name="${column2.name}"  type="int"/>  
         </createTable>  
    </changeSet>
</databaseChangeLog>

Thank you for submitting this issue, @joserebelo!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
8 participants