sqlFile tag not expanding placeholders

Hi,

I have the following bit of code in a file schema.sql:

    IF EXISTS ( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[${cmuser}].[ms_schema_create_site]') AND type in (N'P', N'PC') ) DROP PROCEDURE [${cmuser}].[ms_schema_create_site]

When this schema.sql file is run via a sqlFile tag - the ${variable} placeholders are not expanded. This works OK in a sql tag. Are there any plans on supporting placeholder expansing with sqlFile tag files? We use placeholders extensively for our scripts - and it would be unfortunate to have to paste them all into sql tags.

Thanks,

Ben

I’m on a 2.0 RC2 build.

It’s not something I had thought of, but it may be a good idea. I’ve generally thought of the included .sql files as files that would normally be ran against a database but are being managed by liquibase instead of directly, and if you add ${} blocks, your SQL will not execute on it’s own outside of liquibase.  That may be OK, though, since you would only put them in if you are using liquibase. 

I’ll add it as a feature for 2.1. 

Nathan

That’d be great thanks.

The reason I’m hitting it is that I’m porting all our legacy SQL scripts over - many of which make use of Oracle sqlplus’s $1 parameter functionality and MS SQL Server sqlcmd’s $(variable) parameter substitution. Some of these scripts cannot easily be moved into containing tags.

Ben

Those may be OK still.  The variable substitution will only look for ${}'s so oracle will be OK.  It will also keep ${} variables it doesn’t recognize as their original value, so it will probably work with sqlserver as well, depending on if there is any overlap between your liquibase and sqlserver variable names.

Nathan

http://liquibase.jira.com/browse/CORE-641

This seems to be buggered again in 3.0.7 - placeholders are not being replaced in included sqlFile’s.

I reopened the bug and will look at it with 3.0.8. Thanks


Nathan

Hi,


With version 3.0.8, it tried to replace : 


  1. Liquibase update Failed: Migration failed for change set V1.008/Ginko/dev.xml::Parametrage Ginko - DEV::asc:

         Reason: liquibase.exception.DatabaseException: Error executing SQL BEGIN

            PKG_PARAMETRE.INSERER_PRM_POUR_CDV( ‘URL_APPLICATION’, ‘${prm.expl}’, ‘${prm.cdv}’, ‘str’, ‘${prm.host}’ );

    END;: ORA-01403: aucune donnee trouvee 
    It seems for me that the params were not subtituted.


    With looking at the bug tracker, I thougt the problem was solved in v3.0.8.

    Is there something I’m doing wrong ?



There was a fix for some places, but no in sqlFile. That is now in the upcoming 3.1.0 release which should be out today or tomorrow.


Nathan

Hi

I tried parameter replacement in 3.2.0 against oracle and it didn’t work for .

It did work for .


This is the command line I’m using


java -DchangeId=1405045580= -jar …/…/…/standaloneCmdLineExample/liquibase-3.2.0-bin/liquibase.jar --defaultsFile=./liquibase.properties --changeLogFile=./simpleSQLFileExamplechangelogfile.xml update


This is the change log file


<?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">

      


Yes, I’ve noticed this as well, but nobody has responded.

 

http://forum.liquibase.org/topic/sqlfile-property-replacement-in-3-2-0

 

 

Sorry for the slow response, but it has been fixed for 3.2.1. That release should hopefully be out today.

Nathan