Skip to content

refactor(jdbc): extract result-set value reads - #277

Merged
magnusp merged 1 commit into
mainfrom
refactor/result-set-value-reader
Oct 31, 2026
Merged

magnusp merged 1 commit into
mainfrom
refactor/result-set-value-reader

Conversation

@magnusp

@magnusp magnusp commented Oct 31, 2026

Copy link
Copy Markdown
Owner

What changed

Moved the read-side Hrana value conversion out of LibsqlResultSet into a new package-private JdbcValueReader, the counterpart of the existing JdbcValueConverter. LibsqlResultSet now reads as navigation, column resolution, and the JDBC surface. JdbcValueReader owns the conversion of one stored value to the Java value a getter returns.

The getObject(int, Class) conversion body moved with it. The public override still owns the null-type check, the declared-type rejection, and the JDBC contract javadoc.

Behavior preserved

Every exception type and message is unchanged. Every getter returns the same value for the same storage class and declared type. The getObject fast path and the type if-chains moved byte for byte. The public API is unchanged.

Pins added

Test Behavior pinned
declaredNumericTextRejectsANonNumberWithTheXerialMessage Declared numeric text parses strictly and keeps Bad value for type numeric: abc.
declaredNumericBlobRejectsANonNumberWithTheXerialMessage Declared numeric blob parses strictly with the same message.
declaredTinyIntRejectsAValueOutsideTheIntRange getObject keeps Value N does not fit the declared TINYINT type.
bigDecimalRejectsNonNumericText getBigDecimal keeps Bad value for type BigDecimal: abc.
urlRejectsMalformedText getURL keeps Bad value for type URL: not a url.
offsetTimeRejectsMalformedText getObject(OffsetTime.class) keeps Bad value for type OffsetTime: abc.
offsetDateTimeAcceptsTheSqliteSpaceSeparator The space separator still normalizes to T before parsing.
typedIntegerTargetOnTextStorageUsesTheTargetTypeMessage getObject(Integer.class) on TEXT keeps Bad value for type Integer.

Mutant kills

Probe Result
Change the strict numeric message from numeric to number. 2 pins failed. Reverted.
Change the getObject numeric gate to always true. 1 pin failed. Reverted.

Diff (file statistics)

 JdbcValueReader.java                       | 472 +++++++++++++++++++++
 LibsqlResultSet.java                       | 463 ++------------------
 LibsqlResultSetConversionTest.java         | 106 +++++
 3 files changed, 606 insertions(+), 435 deletions(-)

Line counts

File Before After
LibsqlResultSet.java 1244 837
JdbcValueReader.java 0 472

Probe

The first probe changed the strict numeric parse message in the moved code. Two pins failed, and the message was restored. The second probe removed the storage-class gate in getObject, and the new typed-target pin failed. Both probes left no change.

Lanes

Command Result
mise exec -- ./mvnw -pl libsql-jdbc -am test Pass, 1565 tests (baseline 1557 plus 8 pins).
mise exec -- ./mvnw spotless:check Pass.
mise exec -- ./mvnw -pl libsql-conformance -am verify Pass, 271 tests, 6 skipped.
DOCKER_CONFIG=... mise exec -- ./mvnw -pl libsql-itests -am verify Pass, 43 driver ITs and 192 itests. The first attempt hit a RootlessKit port collision for Ryuk; the retry passed.
  • My code follows the code style of this project (./mvnw spotless:check).
  • I have added tests that prove my fix is effective or that my feature works.
  • All new and existing tests passed (./mvnw clean verify).
  • I have updated documentation where appropriate.

Closes #276

@magnusp
magnusp merged commit 40f45c2 into main Oct 31, 2026
6 checks passed
@magnusp
magnusp deleted the refactor/result-set-value-reader branch October 31, 2026 10: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.

Extract result-set value reads into JdbcValueReader

1 participant