Flyway fails in recognizing correct placeholder "${"

Viewed 246

I have recently been trying to upgrade flyway from v4 to v6.5.3. During the process, I faced an issue related to placeholders.

The migration fails with the following error.

ERROR: Unable to parse statement in D:\Softwares\flyway-commandline-6.5.5-windows-x64\flyway-6.5.5\sql\V3__mysql-7.0.sql at line 101 col 1. See https://flywaydb.org/documentation/knownparserlimitations for more information: No value provided for placeholder: ${'), NOW(), NOW())}. Check your configuration! Caused by: No value provided for placeholder: ${'), NOW(), NOW())}. Check your configuration!

SQL,

insert into `configuration`(key, value, created_date , updated_date) values('LOG_LOCATION', REPLACE('${MY_LOG_LOCATION}','#{','${'), NOW(), NOW());

To resolve the above failure, I replaced "${" with "$\{", but this is something I didn't look out for.
On debugging the flyway code, I saw it fails in parsing (during validation, method org.flywaydb.core.internal.parser.Parser.readToken()) of the SQL.

Why is it considering the 3rd argument of REPLACE function as a placeholder?

Note: The above SQL works in Flyway v4

1 Answers

If you read the documentation here, you can see that flyway uses a particular syntax for it's placeholders, ${somestring}. In your code, you have a ${, but it's not defining a placeholder. While Flyway is a pretty sophisticated tool, the mechanism here is simply using string matching. If you want to, you can modify your Flyway instance to use different escape characters for the placeholders. This could be handy if you have to have strings in your code that match that ${ syntax. You can read about that here. Scroll down to where you define the PlaceHolderPrefix and PlaceHolderSuffix. Change those to a different combination of values that are not used in your code and you should be fine.

Related