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

Wrong multiline query parsing #129

Closed
snuyanzin opened this issue Sep 7, 2018 · 3 comments
Closed

Wrong multiline query parsing #129

snuyanzin opened this issue Sep 7, 2018 · 3 comments

Comments

@snuyanzin
Copy link
Collaborator

snuyanzin commented Sep 7, 2018

The problem appears for queries if any non-last their line ends with ; as sqlline does not care if this ; is a part of constant or comment. Also sqlline does not care of multiline comments at all. For instance

select ';
';
select --;
'123';
select /*
just a comment
*/
'1';

It makes sense to resolve this issue after migration to Jline3 #115 is done as jline3 provides possibility to extend org.jline.reader.impl.DefaultParser in such a way

@snuyanzin
Copy link
Collaborator Author

snuyanzin commented Sep 12, 2018

Currently done for shell mode and all mentioned queries work there (done based on #115 at
486a91d )
Parsing files are in progress
Sqlline prompt while multiline query editing will look like

Prompt Meaning
sqlline> Ready for a new query
semicolon> Waiting for next line of multiple-line query, waiting for completion of query with semicolon (;)
quote> Waiting for next line, waiting for completion of a string that began with a single quote (')
dquote> Waiting for next line, waiting for completion of a string that began with a double quote (")
*/> Waiting for next line, waiting for completion of a multiline comment that began with /*

for example

0: jdbc:calcite:model=example/csv/target/test> select 'multiline ;
. . . . . . . . . . . . . . . . . . . . quote> value'
. . . . . . . . . . . . . . . . . . semicolon> /*
. . . . . . . . . . . . . . . . . . . . . .*/> "just 'a'
. . . . . . . . . . . . . . . . . . . . . .*/> comment";
. . . . . . . . . . . . . . . . . . . . . .*/> */
. . . . . . . . . . . . . . . . . . semicolon> ;
+-------------------+
|      EXPR$0       |
+-------------------+
| multiline ;
value |
+-------------------+
1 row selected (0.035 seconds)
0: jdbc:calcite:model=example/csv/target/test> 

@snuyanzin
Copy link
Collaborator Author

Parsing files are in progress

3774b1e added support for files (branch https://github.com/snuyanzin/sqlline/tree/SQLLINE_129)
as soon as #115 will be merged will make a PR

@julianhyde
Copy link
Owner

Fixed in 77cd467, PR #159. Thanks @snuyanzin!

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

No branches or pull requests

2 participants