I am trying to read SQL files in liquibase using the sqlFile tag. The problem is that when I use the updateSQL command all the non latin characters are replaced by question marks.
I use maven and configured the liquibase-maven-plugin as follows :
this is a quite boring issue, in addition it is very easy to fix directly the code. Is there a specific process to submit patch? The issue can be resolved with few lines of code. This is the fix for 3.0.0-rc3-SNAPSHOT:
In AbstractLiquibaseMojo.java add: /** * Flag to set the character encoding of the output file produced by Liquibase during the updateSQL phase. @parameter expression="${liquibase.outputFileEncoding}" */ protected String outputFileEncoding;
In LiquibaseUpdateSQL.java substitute:
line 68: outputWriter = new FileWriter(migrationSqlOutputFile);
with: if (outputFileEncoding==null) { getLog().warn(“Charser encoding not set! The created file will be system dependent!”); outputWriter = new FileWriter(migrationSqlOutputFile); } else { getLog().info(“Writing output file with [” + outputFileEncoding + “] file encoding.”); outputWriter = new BufferedWriter(new OutputStreamWriter( new FileOutputStream(migrationSqlOutputFile), outputFileEncoding)); }
These simple changes allow the user to specify the charset directly in the pom.xml: