Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treat line breaks as whitespace #42

Open
jansvajcr opened this issue Sep 2, 2019 · 3 comments
Open

Treat line breaks as whitespace #42

jansvajcr opened this issue Sep 2, 2019 · 3 comments

Comments

@jansvajcr
Copy link

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.

@jansvajcr
Copy link
Author

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.

@patka
Copy link
Owner

patka commented Sep 2, 2019

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

@jansvajcr
Copy link
Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants