cassandra-migration
cassandra-migration copied to clipboard
Treat line breaks as whitespace
I have my .cql scripts written as following:
CREATE KEYSPACE IF NOT exists tagservice
WITH replication = ...
During migration on the startup, following exception is thrown:
Caused by: com.datastax.driver.core.exceptions.SyntaxError: line 1:45 missing K_WITH at 'replication' (...KEYSPACE IF NOT exists tagserviceWITH [replication] =...)
It looks like the line breaks are not treated as a separating whitespace. If those are manually added at the beginning of the line (spaces or tabs), the migration is performed succesfully.
The problem root is obviously located in the MigrationRepository#readResourceFileAsString
where the resource file (.cql) is read line by line using the BufferedReader#lines
method which does not preserve line break characters. Therefore, adjacent lines are appended to the StringBuilder
without any separating character.
Hi,
that is correct, which is why the README says "The script format is rather simple. It allows one statement per line and lines should be finished with a ';' character." Currently this is intended by design ;-)
By the time I wrote the library the goal was to go for a rather simple solution that does not require sophisticated parsing of the input files. If you have any ideas how to solve this more elegant I am open for suggestions as I currently do not have much time to work on this (renovating a house next to the job) which is why I put my priorities on bug fixing and critical features that pop up.
Cheers Patrick
Looking at the SimpleCQLLexer
and seeing those cases for '\n' made me a bit confused. I thought it is already multiline-compatible. Thanks for your reply!