Skip to content

fix(jdbc): resolve SqlTableReference literal, alias, and join misreads - #132

Merged
magnusp merged 2 commits into
mainfrom
fix/i110-parser-misreads
Oct 22, 2026
Merged

magnusp merged 2 commits into
mainfrom
fix/i110-parser-misreads

Conversation

@magnusp

@magnusp magnusp commented Oct 22, 2026

Copy link
Copy Markdown
Owner

Fixes #110

Contract: Hrana 3 is the source of truth for transport, values, metadata, batching, transactions, and error reporting; java.sql is the source of truth for the JDBC surface; xerial/sqlite-jdbc is the behavioral reference and conformance foundation, never a copy target. The protocol supplies column names and decltype but no table origin, so SqlTableReference follows SQLite syntax for origin and nullability.

Red

At trunk, with the new cases only: ./mvnw -pl libsql-jdbc test -Dtest=SqlTableReferenceTest gives Tests run: 29, Failures: 7, one failing case per defect (string/blob literals, operator aliases, NOT INDEXED, left()/right(), unresolved CTE, USING column, RETURNING alias). Log: /tmp/xerial-parity-i110/lane-1-trunk.log.

Green

At the PR head: Tests run: 29, Failures: 0. Lanes 2-10 pass: parser+metadata 59, #100 width guard 2, module suite 233, conformance 115, xerial control, spotless, reactor 233, RSMetaDataTest 13, package. Perf: trunk median 2.34s vs head 2.25s, within the 10% rule.

Changes

  • tokenize emits a LITERAL token for '...' and x'...', so literals never reach the parser as words.
  • Implicit aliases reject operator keywords on the last token (ISNULL and NOTNULL added), so CASE ... END and x ISNULL do not alias, and count(*) c now finds c.
  • NOT INDEXED consumes two tokens; LEFT and RIGHT start a join only before JOIN or OUTER.
  • Unresolved CTEs register as opaque sources; an unqualified USING column resolves to the left table; RETURNING honours AS alias on the INSERT/UPDATE/DELETE target.
  • The Column origin resolution shifts after SELECT * when the expanded width differs from SQLite #100 width guard is unchanged and its cases stay green.

Divergences

  • The RETURNING target alias is read after an explicit AS only. SQLite's grammar spells the alias that way, and accepting a bare following word would misread VALUES or SET as an alias.
  • Unqualified NATURAL-join columns keep their existing ambiguous resolution; this issue names USING only.

@magnusp
magnusp merged commit 4725e83 into main Oct 22, 2026
5 checks passed
@magnusp
magnusp deleted the fix/i110-parser-misreads branch October 22, 2026 22:08
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.

SqlTableReference parser misreads literals, operator keywords, NOT INDEXED, and shadowed CTEs

1 participant