Repository navigation
fix(sqlite): run multi-statement batches in source order - #470
Merged
Merged
Conversation
The SQLite connector split a batch into writes and reads and ran all writes before any reads, so `SELECT ...; DELETE ...; SELECT ...` read the table after the DELETE and returned an empty first result. Run each statement in the order written instead, matching the PostgreSQL connector. The per-statement read-only backstop and maxRows probe are unchanged.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The implementation is focused, preserves existing safeguards, and includes appropriate integration coverage.
0 open findings
What changed in this PR
Runs SQLite multi-statement batches in source order, aligning results with statement order.
Changes:
- Executes each SQLite statement sequentially.
- Adds and updates integration coverage for ordering and row limits.
| File | Description |
|---|---|
src/connectors/sqlite/index.ts |
Preserves source execution order. |
src/connectors/__tests__/sqlite.integration.test.ts |
Verifies ordering and updated semantics. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
tianzhou
approved these changes
Oct 10, 2026
tianzhou
left a comment
Member
There was a problem hiding this comment.
LGTM. Thanks for the contribution.
Contributor
Author
|
Thanks @tianzhou for the quick review and merge. |
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.
Summary
The SQLite connector splits a multi-statement batch into writes and reads and runs all writes before any reads. A read that comes before a write in the batch therefore sees the write's effects:
returns
DELETE (3), thenbefore_delete: [], thenafter_delete: 0. The first SELECT comes back empty and the result sets are reordered. PostgreSQL (and MySQL/MariaDB via native multi-statement) run in source order.The split dates from when writes were batched through
.exec()for speed (16e870b). Writes now run one at a time viaprepare().run(), so it no longer buys anything. This PR runs each statement in the order written and branches onreturnsRows()per statement. The per-statementPRAGMA query_only = ONre-assert and the maxRows truncation probe are unchanged.I updated
should handle maxRows in multi-statement execution, which asserted the writes-first order. If that order is intended, happy to close this and keep the behavior documented instead.Test plan
should execute multi-statement batches in source order(fails on main, passes here)should handle maxRows in multi-statement execution, which asserted the writes-first orderpnpm test:unit: 1201/1201SELECT ...; PRAGMA query_only = OFF; DELETE ...