Skip to content

refactor(jdbc): extract xerial column type mapping - #221

Merged
magnusp merged 1 commit into
mainfrom
refactor/i203-column-type-mapping
Oct 24, 2026
Merged

magnusp merged 1 commit into
mainfrom
refactor/i203-column-type-mapping

Conversation

@magnusp

@magnusp magnusp commented Oct 24, 2026

Copy link
Copy Markdown
Owner

Summary

Extracts the xerial 3.53.4.0 column type mapping out of LibsqlResultSetMetaData into a package-private XerialColumnType. Move only: the ordered if-chain, the storage-class helper, className, the storage-class enum, and the single integer(Value) helper (also used by toTableInfo).

  • XerialColumnType holds storageClass(Value), jdbcType(Value, String), className(Value), integer(Value), and the StorageClass enum.
  • getColumnType, getColumnClassName, and isSigned delegate.
  • getColumnType keeps the original evaluation order: getColumnTypeName before runtimeValue.

Nothing else changes. No test, pom, declared-type parsing, AUTOINCREMENT parser, or table resolver touched.

Fixes #203

Verbatim proof (normalized diff, empty)

Moved blocks: old LibsqlResultSetMetaData 188-272 (getColumnType body), 311-325 (className), 366-380 (storageType), 518-528 (integer + SampleType). Compared against the corresponding blocks in XerialColumnType.

Normalization is renames plus visibility only: SampleType -> StorageClass, storageType -> storageClass, and the private modifier dropped because the moved members are package-private by design.

$ F=libsql-jdbc/src/main/java/com/github/magnusp/libsql/jdbc/LibsqlResultSetMetaData.java
$ NORM='s/SampleType/StorageClass/g; s/storageType/storageClass/g; s/^([[:space:]]*)private /\1/'
$ git show origin/main:$F | sed -n '188,272p;311,325p;366,380p;518,528p' | sed -E "$NORM" > /tmp/probe-old.txt
$ sed -n '13,97p;100,114p;116,130p;132,142p' \
    libsql-jdbc/src/main/java/com/github/magnusp/libsql/jdbc/XerialColumnType.java | sed -E "$NORM" > /tmp/probe-new.txt
$ diff -u /tmp/probe-old.txt /tmp/probe-new.txt && echo NORMALIZED_DIFF_EMPTY
NORMALIZED_DIFF_EMPTY
$ wc -l /tmp/probe-old.txt /tmp/probe-new.txt
 126 /tmp/probe-old.txt
 126 /tmp/probe-new.txt

Branch order, the NULL participation in every storage block before Types.NUMERIC, the declared type name set (UNSIGNED BIG INT, DATETIME included), className returning Object.class for NULL/BLOB, and the narrow isSigned set (NUMERIC, INTEGER, REAL) all move unchanged. integer(null) is still 0.

Probe

Deleted the BOOLEAN arm from the INTEGER branch in XerialColumnType.jdbcType, then ran the declared-type test:

$ ./mvnw -pl libsql-jdbc -am test -Dtest=LibsqlResultSetMetaDataTest -Dsurefire.failIfNoSpecifiedTests=false
[ERROR] Tests run: 36, Failures: 3, Errors: 0, Skipped: 0
[ERROR]   LibsqlResultSetMetaDataTest.usesDeclaredTypesWhenRuntimeValueIsNull:241->assertDeclaredTypes:506
expected: 16
 but was: 2
[ERROR]   LibsqlResultSetMetaDataTest.usesDeclaredTypesForEmptyResultSet:261->assertDeclaredTypes:506
expected: 16
 but was: 2

16 is Types.BOOLEAN, 2 is Types.NUMERIC. Reverted; git status clean apart from the two intended files, and the full lane is green again.

Line counts

File Before After
LibsqlResultSetMetaData.java 544 417
XerialColumnType.java — 143

Gates

Lane Result
./mvnw -pl libsql-jdbc -am test 392 tests, 0 failures, 0 errors, 0 skipped
./mvnw spotless:apply then ./mvnw spotless:check BUILD SUCCESS both
./mvnw -pl libsql-conformance -am verify 272 tests, 0 failures, 0 errors, 7 skipped

Baseline on main: 392 JDBC tests and 272 conformance tests (7 skipped). No assertion edited.

@magnusp
magnusp merged commit da2a2d0 into main Oct 24, 2026
6 checks passed
@magnusp
magnusp deleted the refactor/i203-column-type-mapping branch October 24, 2026 15:17
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.

Extract the xerial column type mapping from LibsqlResultSetMetaData

1 participant