Fix transaction, statement lifecycle and cursor bugs in the driver - #28
Merged
Conversation
…outine in SQLite3Cursor
…fected from execute, correct exec/prepare/bind external callback types
…drop redundant nullable helper
…_BUSY on close, await endTransaction in tests
Qodana Community for JVMIt seems all right 👌 No new problems were found according to the checks applied View the detailed Qodana reportTo be able to view the detailed Qodana report, you can either:
To get - name: 'Qodana Scan'
uses: JetBrains/qodana-action@v2025.2.3
with:
upload-result: trueContact Qodana teamContact us at qodana-support@jetbrains.com
|
…perties, fix reported issues
…ch does not support current config
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.
Motivation
Started as a cleanup of
suspendCoroutinecancellation warnings. Auditing call sites turned up real correctness bugs, most seriously: every transaction after first silently committed instead of rolling back.Notes
Each fix ships with a test that fails against the old code:
endTransactionrestored itself instead of enclosing transaction, so second and latertransaction { }blocks skipped bothBEGINandROLLBACKand silently committed.executeQueryhad no cleanup path. It now owns statement lifetime viatry/finally, with check so transaction-cached statements stay owned byendTransaction. RemovesSQLITE_BUSYwarnings on close.executealways returned 0 instead of rows affected.executeAsFlowwas not cold: cursor was created eagerly and captured, so second collection yielded nothing. Now a plainflow { }; oldcallbackFlowregistered no callbacks.get/exec/prepare/bindcallbacks haderrmisnamedselfand typed non-null. Corrected againstsqlite3.d.ts.resetdeliberately left asNothing?; upstream really does always pass null.suspendCancellableCoroutinethroughout, dead cursor state removed,nullablehelper dropped (it was an identity function).Commits are ordered so each one builds and passes on its own.
Heads-up
executereturning real counts is a user-visible change from old constant0.QueryResultcompletes. SQLDelight accessors consume cursor inside mapper and are unaffected, but a custom mapper holding cursor past that point would break.