fix(query): handle semicolons inside string literals#131
Merged
ErikBjare merged 1 commit intoActivityWatch:masterfrom Feb 27, 2026
Merged
fix(query): handle semicolons inside string literals#131ErikBjare merged 1 commit intoActivityWatch:masterfrom
ErikBjare merged 1 commit intoActivityWatch:masterfrom
Conversation
The query parser was using query.split(';') to separate statements,
which incorrectly split on semicolons inside string literals, causing
QueryParseException for valid queries like 'RETURN = "hello;world"'.
Replace with _split_query_statements() that tracks quote state and
only splits on semicolons that are actual statement terminators.
Fixes ActivityWatch/aw-server#145
There was a problem hiding this comment.
Important
Looks good to me! 👍
Reviewed everything up to 66a8d55 in 19 seconds. Click for details.
- Reviewed
101lines of code in2files - Skipped
0files when reviewing. - Skipped posting
0draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
Workflow ID: wflow_GAPARiHB1JtmEPPa
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
Greptile SummaryThis PR fixes a bug where semicolons inside string literals caused the query parser to incorrectly split statements. The fix replaces the naive Key Changes:
Testing:
Confidence Score: 5/5
Important Files Changed
Last reviewed commit: 66a8d55 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes ActivityWatch/aw-server#145.
The query parser was using
query.split(';')to separate statements, which incorrectly split on semicolons inside string literals, causingQueryParseExceptionfor valid queries like:Root Cause
In
aw_query/query2.py, thequery()function did:This splits on all semicolons, including those inside string literals. The rest of the parser correctly handles string tokenization (see
QString.check()), but statement splitting happened before tokenization.Fix
Replace
query.split(";")with a new_split_query_statements()function that tracks quote state (single/double) and only splits on semicolons that are actual statement terminators — not those inside string literals.Tests
Added:
test_query2_semicolon_in_string— end-to-end query tests with semicolons in stringstest_split_query_statements— unit tests for the new splitter functionAll 29 existing tests continue to pass.
Important
Fixes query parsing to handle semicolons inside string literals by replacing
splitwith a custom function inquery2.py.query.split(";")with_split_query_statements()inquery()inquery2.pyto correctly handle semicolons inside string literals._split_query_statements()tracks quote state to avoid splitting within string literals.test_query2_semicolon_in_stringfor end-to-end testing of semicolons in strings.test_split_query_statementsfor unit testing the new splitting function.This description was created by
for 66a8d55. You can customize this summary. It will automatically update as commits are pushed.