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.
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.
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.
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.