Skip to content

fix(jdbc): report runtime storage class from getColumnType - #63

Merged
magnusp merged 1 commit into
mainfrom
fix/35-runtime-storage-type
Oct 21, 2026
Merged

magnusp merged 1 commit into
mainfrom
fix/35-runtime-storage-type

Conversation

@magnusp

@magnusp magnusp commented Oct 21, 2026

Copy link
Copy Markdown
Owner

Closes #35. Part of #54.

What changed

  • LibsqlResultSetMetaData.getColumnType now checks the current row's runtime storage class before consulting the declared type, following xerial 3.53.4.0 JDBC3ResultSet.getColumnType (JDBC3ResultSet.java:622-721) branch by branch.
  • Added the shared package-private read-only accessor LibsqlResultSet.valueForMetadata(int). It returns the value at the metadata cursor: the first row before the first next() (matching xerial's preloaded first row), the current row during iteration, and null at end-of-results so declared types apply.
  • Added behavior tests for BIGINT holding 1.5, BOOLEAN holding 'true', NUMERIC and DECIMAL holding integers, NULL values, an empty result set, and type changes between rows.
  • Removed the now-unused cross-row integerType and inferTypeFromValue helpers.

Contract decision

Runtime typing wins, matching xerial 3.53.4.0 and the #54 parity rule. getColumnType is gated on the current row's storage class, including NUMERIC/DECIMAL holding an integer reporting INTEGER. NULL or no current row falls back to declared-type mapping, which also covers empty result sets.

Evidence

Failing before the fix:

mise exec -- ./mvnw -pl libsql-jdbc -am -Dtest=LibsqlResultSetMetaDataTest -Dsurefire.failIfNoSpecifiedTests=false test
[ERROR] Tests run: 13, Failures: 2, Errors: 0, Skipped: 0
[ERROR] LibsqlResultSetMetaDataTest.usesRuntimeStorageClassForDeclaredTypes:164->assertRuntimeTypes:232
expected: 6
 but was: -5
[ERROR] LibsqlResultSetMetaDataTest.reflectsStorageClassChangesBetweenRows:219
expected: 6
 but was: -5

Passing after the fix:

mise exec -- ./mvnw -pl libsql-jdbc -am -Dtest=LibsqlResultSetMetaDataTest -Dsurefire.failIfNoSpecifiedTests=false test
Tests run: 13, Failures: 0, Errors: 0, Skipped: 0
BUILD SUCCESS

mise exec -- ./mvnw -pl libsql-jdbc -am test
Tests run: 65, Failures: 0, Errors: 0, Skipped: 0
BUILD SUCCESS

mise exec -- ./mvnw -pl libsql-conformance -am verify
Tests run: 106, Failures: 0, Errors: 0, Skipped: 1
BUILD SUCCESS

The conformance run includes the vendored xerial RSMetaDataTest against live sqld (13 tests, all passed). mise exec -- ./mvnw spotless:apply completed with no formatting changes.

Deviations

None.

@magnusp
magnusp force-pushed the fix/35-runtime-storage-type branch from cb8dd0a to a6d3f55 Compare October 21, 2026 22:12
@magnusp
magnusp merged commit 6fc9a08 into main Oct 21, 2026
5 checks passed
@magnusp
magnusp deleted the fix/35-runtime-storage-type branch October 21, 2026 22: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.

getColumnType ignores runtime storage class

1 participant