-
-
Notifications
You must be signed in to change notification settings - Fork 90
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
Queries cannot contain a string literal or quoted name with a semicolon (e.g., ';'
)
#348
Comments
Now that the editor has tree-sitter onboard, consider using a tree-sitter query to find query delimeters. Actually the grammar looks very complete; it's just the highlight query that is very simplistic. |
just spent time on this. The tree-sitter grammar isn't good enough or maybe is just too rigid. Lots of valid queries return errors. There is also a problem with set operations: the parser doesn't know about That means the options are:
|
sqlglot frustratingly doesn't include token coordinates in the AST. So we could use it for splitting queries to send to the db, but not for finding the query where the cursor currently is. Could use Dialect.tokenize and run through the token stream instead, looking for semicolons; this is what parse does to split things into chunks. |
I just run into this with an even more confusing behavior: As some prompts require the SQL statements to be terminated with a semi-colon, I had added one to the end of the query. When the semi-colon is the last character of the prompt, trying to run the prompt works fine. But if it's not the last character, e.g. another new line or space after the semi-colon, then just nothing happens when trying to run the query. This behavior is extremely confusing, as there is no error message or anything hinting on the issue. It just feels weirdly broken. I guess the queries should be just trimmed automatically before execution. |
It's true that we split on semicolons and don't include them in the queries we send to the db. We could change that. But I don't understand why it's an issue? What rdbms are you using that requires that queries or statements are terminated by a semicolon? Can you provide an example that doesn't work? |
';'
)
';'
)';'
)
Describe the bug
Harlequin naively splits query text on
;
, even if that is inside a quote or identifier.To Reproduce
select ';' as a
, then try to run queryExpected behavior
This query should execute fine.
Actual behavior
Harlequin shows a syntax error, since it splits the query as
select '
Additional context
What is the output of
harlequin --version
?1.6.0
What database adapter are you using with Harlequin? (Default is DuckDB)
DuckDB (affects all)
System:
The text was updated successfully, but these errors were encountered: