There is a liquibase parameter in Spring boot, let's say:
spring.liquibase.parameters.val1 = value1
I want to use this parameter in a sql file like this:
insert into table1 (name, value) values ("nameOfValue", ${val1});
unfortunately, the only combination that so far worked was putting 3 single quotes - '''${val1}'''
(which gives 'value1'
) and substring
removing the first and last single quote.
Is there a more clean way of using liquibase parameters in an INSERT statement in SQL changeset files?
It looks like you don't have to do anything special to insert a parameter from the properties no matter the chosen format of the changeset.
All of the following will result in valid insert statements.
SQL changeset
--changeset me:2
insert into test1 (id, name) values (1, 'name 1');
insert into test1 (id, name) values (3, '${val1}');
YAML changeset
- changeSet:
id: 2
author: me
changes:
- sql:
endDelimiter: ;
sql: >-
insert into test1 (id, name) values (1, 'name 1');
insert into test1 (id, name) values (3, '${val1}');
XML changeset:
<changeSet id="2" author="me">
<sql endDelimiter=";">
insert into test1 (id, name) values (1, 'name 1');
insert into test1 (id, name) values (3, '${val1}');
</sql>
</changeSet>