Skip to content

fix(jdbc): return canonical REAL text from getBytes (#74) - #121

Merged
magnusp merged 1 commit into
mainfrom
fix/i74-real-bytes
Oct 22, 2026
Merged

magnusp merged 1 commit into
mainfrom
fix/i74-real-bytes

Conversation

@magnusp

@magnusp magnusp commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner

Summary

LibsqlResultSet.getBytes(int) encoded REAL values with Double.toString, so 0.0001 came back as 1.0E-4 and disagreed with getString. REAL values now go through the existing sqliteRealText helper, so getBytes returns the same SQLite canonical text bytes as getString (0.0001, 10000000.0, 1.0e+20).

Contract. Hrana 3 is the source of truth for transport, values, and metadata. java.sql is the source of truth for the JDBC surface. xerial/sqlite-jdbc 3.53.4.0 is a behavioral reference only. Hrana Value has no text form for a float, so the driver formats locally, targeting the text the server produces for CAST(value AS TEXT). That is a SQLite conversion rule, not a protocol field and not an xerial quirk.

Fixes #74

Changes

  • LibsqlResultSet.getBytes(int) routes Value.Float through sqliteRealText. One-line change; the BLOB, TEXT, INTEGER, and NULL branches are untouched.
  • LibsqlResultSetRealTextTest pins getBytes against the canonical text for all 11 existing cases, including the three issue values, and asserts equality with getString bytes.

Evidence

Red at trunk (277ef8d), ./mvnw -pl libsql-jdbc test -Dtest=LibsqlResultSetRealTextTest: 10 of the 11 new parameters fail. Those include 0.0001 -> 1.0E-4, 10000000.0 -> 1.0E7, and 1e20 -> 1.0E20. 0.0 passes because Double.toString(0.0) already produces 0.0.

Green at head (c0fae0d):

Command Result
./mvnw -pl libsql-jdbc test -Dtest=LibsqlResultSetRealTextTest 25 tests, 0 failures
./mvnw -pl libsql-jdbc test -Dtest='LibsqlResultSetRealTextTest,LibsqlResultSetTest' 43 tests, 0 failures
./mvnw -pl libsql-jdbc test 189 tests, BUILD SUCCESS
./mvnw spotless:check BUILD SUCCESS
./mvnw test BUILD SUCCESS
./mvnw -pl libsql-jdbc -am package -DskipTests driver jar built
./mvnw -pl libsql-conformance -am verify -Dit.test=org.sqlite.ResultSetTest 21 tests, BUILD SUCCESS
./mvnw -pl libsql-conformance -am verify 115 tests, 1 skipped (pre-existing InsertQueryTest skip), no new divergence
./mvnw -pl libsql-conformance -am -Pxerial-control verify 100 tests, 1 skipped, BUILD SUCCESS

BLOB and TEXT getBytes are unaffected: the diff touches only the Value.Float branch, and the vendored ResultSetTest, which exercises getBytes on INTEGER and TEXT, stays green.

Perf probe, wall clock of ./mvnw -pl libsql-jdbc test, 3 interleaved runs per side after one warmup: trunk median 2.17 s, head median 2.20 s, head range 2.12 to 3.44 s. No measurable difference, and the metric is dominated by Maven startup.

Divergence

None. This removes an internal divergence between getBytes and getString for REAL. The xerial control lane completed with no failures, and the vendored ResultSetTest stays green.

Base 277ef8d / head c0fae0d.

getBytes encoded REAL values with Double.toString, which produced
1.0E-4 for 0.0001 and disagreed with getString. Route REAL through the
existing sqliteRealText helper so getBytes returns the same SQLite
canonical text bytes as getString and CAST(value AS TEXT).

Fixes #74
@magnusp
magnusp merged commit dea07fa into main Oct 22, 2026
4 checks passed
@magnusp
magnusp deleted the fix/i74-real-bytes branch October 22, 2026 18:53
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.

getBytes returns Double.toString text for REAL values

1 participant