Skip to content

fix(jdbc): convert getBoolean through integer coercion - #62

Merged
magnusp merged 1 commit into
mainfrom
fix/32-getboolean-numeric
Oct 21, 2026
Merged

magnusp merged 1 commit into
mainfrom
fix/32-getboolean-numeric

Conversation

@magnusp

@magnusp magnusp commented Oct 21, 2026

Copy link
Copy Markdown
Owner

Part of #54.

What changed

LibsqlResultSet.getBoolean(int) now delegates to getInt(int) != 0, matching xerial/sqlite-jdbc 3.53.4.0 (JDBC3ResultSet.java:180-182). The old custom truthiness (case-insensitive "true", direct REAL test, blob first-byte test) is gone. Javadoc on the method records the conversion for every storage class: NULL, INTEGER, REAL, TEXT, and BLOB.

New behavior test LibsqlResultSetGetBooleanTest covers the storage-class matrix from the steering: text 'true', '0', '2', REAL 0.5, REAL 2.0, blob x'313233', and NULL, and asserts getBoolean equals getInt != 0 for each. It also pins the corrected probe values for 'true', '2', and 0.5: false, true, false.

Contract decision

Match xerial 3.53.4.0. Boolean conversion goes through integer coercion, so:

Storage Value getInt getBoolean
TEXT 'true' 0 (no numeric prefix) false
TEXT '0' 0 false
TEXT '2' 2 true
REAL 0.5 0 (truncated) false
REAL 2.0 2 true
BLOB x'313233' 123 (text prefix) true
NULL NULL 0 false

This is the parity default from #54. TEXT and BLOB coercion comes from #31's numeric getters, so getBoolean and getInt agree everywhere.

Evidence

Failing before the fix (current main at fca0f14):

./mvnw -pl libsql-jdbc -am -Dtest=LibsqlResultSetGetBooleanTest -Dsurefire.failIfNoSpecifiedTests=false test
Tests run: 8, Failures: 4, Errors: 0, Skipped: 0
  getBooleanConvertsThroughIntegerLikeXerial[...][1] expected: false but was: true   ('true')
  getBooleanConvertsThroughIntegerLikeXerial[...][3] expected: true but was: false   ('2')
  getBooleanConvertsThroughIntegerLikeXerial[...][4] expected: false but was: true   (REAL 0.5)
  reproductionValuesMatchSqliteJdbc expected: false but was: true

Passing after the fix:

./mvnw -pl libsql-jdbc -am -Dtest=LibsqlResultSetGetBooleanTest -Dsurefire.failIfNoSpecifiedTests=false test
Tests run: 8, Failures: 0, Errors: 0, Skipped: 0

Full module suite after the fix:

./mvnw -pl libsql-jdbc -am test
Tests run: 69, Failures: 0, Errors: 0, Skipped: 0
BUILD SUCCESS

./mvnw spotless:apply ran clean before commit.

Deviations

None.

Closes #32

@magnusp
magnusp merged commit b2f086e into main Oct 21, 2026
5 checks passed
@magnusp
magnusp deleted the fix/32-getboolean-numeric branch October 21, 2026 22:12
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.

getBoolean uses custom truthiness instead of numeric conversion

1 participant