Repository navigation
fix(jdbc): coerce numeric getters like sqlite-jdbc - #55
Merged
Merged
Conversation
magnusp
force-pushed
the
fix/31-numeric-coercion
branch
from
October 21, 2026 21:38
0baf822 to
9fae229
Compare
Route getObject(int, Class) numeric targets through strict TEXT parsing instead of the relaxed public getters. Public getInt/getLong/getFloat/getDouble keep SQLite coercion.
magnusp
force-pushed
the
fix/31-numeric-coercion
branch
from
October 21, 2026 21:45
e45dd39 to
ac5a238
Compare
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.
Closes #31. Part of #54.
What changed
getLongandgetDoublenow apply SQLite's text-to-number conversion instead of strictLong.parseLong/Double.parseDoubleparsing.getInt,getByte, andgetShortinherit the conversion viagetLong;getFloatinherits it viagetDouble, so all numeric getters agree.LibsqlResultSetTestfixtures covering non-numeric text, numeric text, REAL text, exponent text, leading whitespace/trailing garbage, numeric blobs, non-numeric blobs, REAL storage, and INTEGER storage. Each case assertsgetInt,getLong,getFloat, andgetDouble.Contract decision
Match xerial 3.53.4.0 (
JDBC3ResultSet.java:304-350, backed bysqlite3_column_int64/sqlite3_column_double) as required by #54's drop-in-replacement goal:sqlite3Atoi64semantics: leading whitespace and sign, decimal prefix only, saturation on overflow,0when no digits. Thus'1.9'->1,'1.5e2'->1,'abc'->0.sqlite3AtoFsemantics: leading whitespace and sign, decimal prefix with optional exponent,0when no mantissa digits.x'313233'->123,x'616263'->0.0for numeric getters, withwasNull()still reportingtrue.Evidence
Before the fix (new tests only):
After the fix:
Additional verification: an ad-hoc probe of the same conversion cases against xerial 3.53.4.0 produced identical
getInt/getLong/getFloat/getDoubleoutput for 29 inputs, including overflow, exponent, whitespace, and negative-zero cases.Deviations
None.