Skip to content

feat(sql): upgrade JSqlParser to 5.4 with token-based syntax reasons - #44

Merged
omer-cengel merged 2 commits into
masterfrom
feature/upgrade-jsqlparser-5.4
Sep 27, 2026
Merged

omer-cengel merged 2 commits into
masterfrom
feature/upgrade-jsqlparser-5.4

Conversation

@omer-cengel

Copy link
Copy Markdown
Member

Summary

Upgrades the SQL parser from JSqlParser 5.3 to 5.4. Version 5.4 removes the SimpleNode API and reports syntax errors with parser-internal token kinds and lexical states, so sqlcj now builds its syntax reasons from the unexpected token itself. Diagnostics stay one line, name no parser internals, and carry a location only for schema sources.

Changes

  • Bump jsqlparser.version to 5.4 and replace the removed SimpleNode with Node in the parameter compiler and its test fixture.
  • Report a syntax failure as Encountered unexpected token: "<image>", escaping line breaks in multi-line tokens, or as Encountered unexpected end of input. Schema sources append at line N, column M; queries keep their existing header-line location.
  • Lexical errors keep the parser's own wording, which 5.4 changes from after prefix to after:.
  • Dollar-quoted text ($$...$$) is one literal and block comments nest, as in PostgreSQL, so a $N inside either stays text and is not bound.
  • Update the affected diagnostic expectations. Add tests for end-of-input failures with and without a location and for a multi-line unexpected token.
  • Update the schema-diagnostic example in the PostgreSQL guide.

Scope and non-goals

  • No new schema statement kinds are accepted, although 5.4 can parse more of them.
  • SQL is not split or pre-processed.
  • Caller message prefixes and lexical-error wording are unchanged apart from the parser's own after: wording.

JSqlParser 5.4 merges SimpleNode into Node and states syntax errors with
parser-internal token kinds and lexical states. Syntax reasons are now
composed from the unexpected token itself: `Encountered unexpected token:
"<image>"` with line breaks escaped, or `Encountered unexpected end of
input`, followed by a location for schema sources only. Lexical errors keep
the parser's wording.

5.4 lexes $$...$$ as one literal and nests block comments as PostgreSQL
does, so a $N inside either is left as text and is not bound.
@omer-cengel
omer-cengel merged commit 4910375 into master Sep 27, 2026
6 checks passed
@omer-cengel
omer-cengel deleted the feature/upgrade-jsqlparser-5.4 branch September 27, 2026 13:38
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