Skip to content

fix: exclude trailing whitespace from quoted hex literals - #2685

Open
minleejae wants to merge 1 commit into
JSQLParser:masterfrom
minleejae:fix/hex-literal-trailing-whitespace
Open

minleejae wants to merge 1 commit into
JSQLParser:masterfrom
minleejae:fix/hex-literal-trailing-whitespace

Conversation

@minleejae

@minleejae minleejae commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

The lexer includes trailing spaces in quoted hex tokens. For SELECT X'6162' AS v, HexValue.getDigits() consequently includes a quote, getLong() throws, and each parse/render cycle adds whitespace. JSON_VALUE DEFAULT expressions and generated columns have the same problem.

Factor the quoted segment into a private lexer fragment and allow separating spaces only when followed by another quoted segment. S_HEX now ends at its final quote. Existing hex spellings and legacy segmented forms remain accepted; the public HexValue API is unchanged.

Validation: ./gradlew check passed. Tests cover numeric/string/blob accessors, whitespace before aliases and FROM, repeated round trips, existing token forms, and editing a JSON_VALUE default through the AST. Five reproductions were executed on MySQL 8.4.11 before and after rendering, with identical results. This fixes token boundaries and AST stability; the original SQL was already executable in MySQL.

Combined validation with #2682, #2683, #2684, #2685 and #2686: all five changes merge without conflicts; the integrated ./gradlew check passes (8,190 tests, 25 skipped). All 254 MySQL 8.4.11 fixtures parse, render and reparse, and execute with results identical to the original SQL.

Signed-off-by: minleejae <mmj9808@gmail.com>

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

1 participant