Repository navigation
Find SQL console clause keywords only outside literals - #59
Merged
Merged
Conversation
The parser searched SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY, UNION SELECT, UP TO n ROWS and INTO/APPENDING in the raw query text, so a literal such as ' from ' or 'x ORDER BY y' split the query at the wrong place, and 'up to 5 rows into x' was cut out of a WHERE literal. Every keyword search now runs in a copy whose literals are blanked out by underscores (mask_literals, same length as the original), and the original is cut at the offsets found there. UP TO and INTO are removed from both copies with replace( off len ), so the offsets stay aligned. Unit tests cover keywords inside literals in WHERE, the select list, HAVING, ORDER BY, UNION SELECT and UP TO/INTO; all five failed before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014YZFmF4CrXfWRsmrwPJTRL
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.
What and why
After #58 the parser kept string literals byte-exact, but it still searched for the clause keywords (
SELECT,FROM,WHERE,GROUP BY,HAVING,ORDER BY,UNION SELECT,UP TO n ROWS,INTO/APPENDING) in the raw query text. Because of that, a literal such as' from 'or'x ORDER BY y'split the query at the wrong place, and'up to 5 rows into x'was cut out of a WHERE literal.mask_literals( )method builds onsplit_literals( ). It returns the same text with every literal, delimiters included, replaced by underscores. The copy has the same length as the original, so an offset found in the copy also points to the right place in the original.parse( )(UNION SELECT) andparse_segment( )(all other keywords) now search the masked copy and cut the original text at the offsets they find.UP TO … ROWSandINTO …are removed from both copies withreplace( off len ), so the two copies stay aligned. Offset access is used only on local strings; no offset access is used on method arguments.Tests
Five new tests in
ltcl_parserput keywords inside literals in WHERE, the select list (CASE … THEN 'from x' …), HAVING, ORDER BY,UNION SELECTandUP TO/INTO. All five failed on the old code and all pass now (25 passed, 0 failed).Checks run
npm run check(Standard ABAP, ABAP Cloud, abap2UI5-linter, rename): 0 issuesnpm run unit: 25/25 passednpm run auto_downportin a scratch copy: the 7.02 lint finds 0 issuesGenerated by Claude Code