Repository navigation
fix(jdbc): return canonical REAL text from getBytes (#74) - #121
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
LibsqlResultSet.getBytes(int)encoded REAL values withDouble.toString, so0.0001came back as1.0E-4and disagreed withgetString. REAL values now go through the existingsqliteRealTexthelper, sogetBytesreturns the same SQLite canonical text bytes asgetString(0.0001,10000000.0,1.0e+20).Contract. Hrana 3 is the source of truth for transport, values, and metadata.
java.sqlis the source of truth for the JDBC surface. xerial/sqlite-jdbc 3.53.4.0 is a behavioral reference only. HranaValuehas no text form for a float, so the driver formats locally, targeting the text the server produces forCAST(value AS TEXT). That is a SQLite conversion rule, not a protocol field and not an xerial quirk.Fixes #74
Changes
LibsqlResultSet.getBytes(int)routesValue.FloatthroughsqliteRealText. One-line change; the BLOB, TEXT, INTEGER, and NULL branches are untouched.LibsqlResultSetRealTextTestpinsgetBytesagainst the canonical text for all 11 existing cases, including the three issue values, and asserts equality withgetStringbytes.Evidence
Red at trunk (
277ef8d),./mvnw -pl libsql-jdbc test -Dtest=LibsqlResultSetRealTextTest: 10 of the 11 new parameters fail. Those include0.0001 -> 1.0E-4,10000000.0 -> 1.0E7, and1e20 -> 1.0E20.0.0passes becauseDouble.toString(0.0)already produces0.0.Green at head (
c0fae0d):./mvnw -pl libsql-jdbc test -Dtest=LibsqlResultSetRealTextTest./mvnw -pl libsql-jdbc test -Dtest='LibsqlResultSetRealTextTest,LibsqlResultSetTest'./mvnw -pl libsql-jdbc test./mvnw spotless:check./mvnw test./mvnw -pl libsql-jdbc -am package -DskipTests./mvnw -pl libsql-conformance -am verify -Dit.test=org.sqlite.ResultSetTest./mvnw -pl libsql-conformance -am verifyInsertQueryTestskip), no new divergence./mvnw -pl libsql-conformance -am -Pxerial-control verifyBLOB and TEXT
getBytesare unaffected: the diff touches only theValue.Floatbranch, and the vendoredResultSetTest, which exercisesgetByteson 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
getBytesandgetStringfor REAL. The xerial control lane completed with no failures, and the vendoredResultSetTeststays green.Base
277ef8d/ headc0fae0d.