Skip to content

fix(jdbc): copy xerial metadata flags and type-name parsing - #73

Merged
magnusp merged 1 commit into
mainfrom
fix/46-metadata-flags
Oct 21, 2026
Merged

magnusp merged 1 commit into
mainfrom
fix/46-metadata-flags

Conversation

@magnusp

@magnusp magnusp commented Oct 21, 2026

Copy link
Copy Markdown
Owner

Closes #46.

Part of #54.

What changed

  • isSigned now follows xerial's narrow type-name set: true only for NUMERIC, INTEGER, and REAL. BIGINT, SMALLINT, DECIMAL, FLOAT, and DOUBLE report false.
  • CAST extraction is case-sensitive, matching xerial: cast(...) is parsed, CAST(...) is not.
  • Declared type names are no longer trimmed, and the prefix before the first ( is uppercased exactly as xerial does. A quoted type such as "BIG INT" now reports BIG INT; " NUMERIC " keeps its spaces.
  • Malformed precision (DECIMAL(abc)) now propagates NumberFormatException from getPrecision instead of returning 0; getScale still returns 0 because the split has one element.
  • An explicitly empty declared type ("") is now treated as present, matching xerial, instead of falling back to runtime sampling.

Contract decision

Parity under #54 is the default, and here parity means copying the xerial 3.53.4.0 quirks deliberately. The case-sensitive CAST pattern, the NumberFormatException on malformed precision, and the narrow isSigned type set are kept on purpose. They are not bugs to "fix" later; changing any of them would break the drop-in contract. Verified against xerial 3.53.4.0 and against sqld/Hrana, which returns the same decltype values for these cases.

Evidence

Tests were added to LibsqlResultSetMetaDataTest first and failed on the pre-fix code (4 failures):

[ERROR] isSignedMatchesXerialNarrowTypeNameSet: [BIGINT] Expecting value to be false but was true
[ERROR] matchesCastOnlyInLowerCase: [uppercase CAST] expected: "INTEGER" but was: "BOOLEAN"
[ERROR] preservesWhitespaceInDeclaredTypeNames: Expecting value to be false but was true
[ERROR] throwsNumberFormatExceptionForMalformedPrecision: Expecting code to raise a throwable

After the fix:

  • ./mvnw -pl libsql-jdbc -am test -> BUILD SUCCESS, 127 tests, 0 failures.
  • ./mvnw -pl libsql-conformance -am verify -> BUILD SUCCESS, 115 tests, 0 failures, 1 skipped (includes vendored org.sqlite.RSMetaDataTest: 13/13 passing).
  • ./mvnw spotless:apply -> BUILD SUCCESS.

Acceptance matrix covered: isSigned for BIGINT, SMALLINT, DECIMAL(10,5), FLOAT, DOUBLE (plus NUMERIC/INTEGER/REAL true cases); upper- and lowercase CAST; quoted type with spaces; DECIMAL(abc).

Deviations

none

@magnusp
magnusp force-pushed the fix/46-metadata-flags branch from 20ebe0c to 319210b Compare October 21, 2026 23:11
@magnusp
magnusp merged commit 7de329f into main Oct 21, 2026
5 checks passed
@magnusp
magnusp deleted the fix/46-metadata-flags branch October 21, 2026 23:15
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.

Scalar metadata flags and type-name parsing diverge

1 participant