Repository navigation
fix(jdbc): stringify REAL values with SQLite canonical text - #68
Merged
Merged
Conversation
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.
What changed
ResultSet.getStringnow renders REAL values with SQLite's canonical text instead ofDouble.toString.getBigDecimalinherits the fix because it parsesgetString, so scale is stable for a given REAL value.printf("%!.17g")(sqlite3FpDecode,sqlite3Fp2Convert10, and the power-of-ten tables). It produces up to 17 significant digits, trims trailing zeros, uses fixed notation for decimal exponents from -4 through 16, and scientific notation with a signed, at least two-digit exponent otherwise. The output always keeps one digit after the decimal point.LibsqlResultSet.getString.LibsqlResultSetRealTextTestcovering the three pinned values,BigDecimalscale andequalsstability, negatives, and the notation boundaries at1e16/1e17and1e-4/1e-5.Contract decision
Match xerial/sqlite-jdbc 3.53.4.0. There is no transport obstacle: Hrana delivers REAL as a JSON number, which the driver parses to the same IEEE-754 double that SQLite formats. Parity, not a deviation.
Evidence
Failing before the fix:
Passing after the fix:
As an additional differential check, the internal formatter was compared against xerial 3.53.4.0's
cast(? as text)for 1,299,525 values (random 64-bit patterns plus random magnitudes across the full double range): 0 mismatches.Deviations
None.
Out of scope
getBytesfor a REAL still builds bytes fromDouble.toString, while xerial returns the canonical text bytes. This is outside this issue's String/BigDecimal scope and was left unchanged.Closes #33