Repository navigation
fix(jdbc): validate prepared statement kind before execution - #57
Merged
Merged
Conversation
magnusp
force-pushed
the
fix/29-validate-statement-kind
branch
from
October 21, 2026 21:37
b5b13fd to
f53b704
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 #29. Part of #54.
What changed
LibsqlPreparedStatementnow classifies the statement kind once, at construction, and rejects wrong-kind calls before any execution:executeQuery()on a non-result statement throwsQuery does not return resultswithout calling the connection.executeUpdate()on a result-producing statement throwsQuery returns resultswithout calling the connection.LibsqlPreparedStatementTestwith behavior tests that record connection execution calls: wrong-kind calls assert zero calls, and right-kind calls still execute and return rows/update counts.INSERT,SELECT,INSERT ... RETURNING, andWITH ... SELECT.Contract decision
Matched xerial 3.53.4.0
JDBC3PreparedStatement.java:73-78,110-116: validate the prepared statement kind before executing, using xerial's exact messages.execute()and the non-preparedLibsqlStatementpaths are unchanged because xerial'sStatementpath still executes before reporting that the result kind is wrong.Evidence
Failing before (production file reverted to
HEAD, new tests kept):Passing after:
The prepared-statement test class runs 6/6 green.
./mvnw spotless:applysucceeds.Deviations
Hrana does not expose SQLite's prepare-time column count without a server round trip, and the steering requires validation before any client call. The driver therefore classifies the kind lexically (comments, quoted literals, parenthesis depth,
RETURNING,WITHbodies, andPRAGMA ... = ...assignments are handled). This is the only transport-forced deviation from xerial'scolumnCountapproach; exotic SQL outside this classification could be treated as a non-result statement.