Repository navigation
Conversation
Local `void db execute` printed results only when the SQL started with `SELECT`, so `WITH`, `PRAGMA`, `EXPLAIN` and `RETURNING` succeeded silently. The remote D1, PostgreSQL and MySQL paths already print rows for any statement that returns them. Ask better-sqlite3 whether the prepared statement reads rows instead of matching the statement text, and leave a multi-statement script on `exec()`, which reports no rows.
Collaborator
Author
|
👁️🗨️ Review this pull request with grouped, summarized diffs at: raw result💭 analyzed by {
"headSha": "eb919dff6844998d123c05e5cc7a4903ce1bec64",
"result": {
"overallSummary": "Fixes the local `db execute` output: rows were printed only when the SQL text started with `SELECT`, so `WITH`, `PRAGMA`, `EXPLAIN` and `RETURNING` succeeded silently. The local path now asks better-sqlite3 whether the prepared statement reads rows (`statement.reader`), matching the remote D1/PostgreSQL/MySQL behavior. **Review order:** the CLI change first, then the tests that pin it, then the one-line doc update.",
"groups": [
{
"key": "local-execute-rows",
"label": "Local execute row printing",
"summary": "Classify the statement by what SQLite reports (`statement.reader`) instead of a `^SELECT` regex, so any row-returning statement prints a table and writes/DDL stay silent. Multi-statement scripts still fall back to `exec()`. The comment/semicolon stripping used by the safety check is extracted into `stripSqlDecoration`, and the sqlite statement type gains the `reader` flag that this relies on.",
"category": "cli",
"filePaths": [
"packages/void/src/cli/db.ts",
"packages/void/src/migrations/runner.ts"
],
"critical": false,
"fileNotes": [
{
"path": "packages/void/src/cli/db.ts",
"text": "Two behavior changes beyond the printed rows: the `No rows returned.` info message is gone (empty results are now silent, like the remote paths), and a failing `prepare()` no longer surfaces when the SQL contains a semicolon - it is re-run through `exec()` instead, which also swallows the fact that nothing was printed."
},
{
"path": "packages/void/src/migrations/runner.ts",
"text": "Type-only addition documenting the better-sqlite3 statement shape; no runtime change."
}
]
},
{
"key": "tests",
"label": "Execute tests",
"summary": "New cases run the unmocked local SQLite path against a real database file so `reader` is exercised for real: `WITH ... SELECT`, `PRAGMA`, `EXPLAIN QUERY PLAN`, a `SELECT` behind a comment and `INSERT ... RETURNING` print tables, while writes, DDL, empty results and multi-statement scripts print nothing.",
"category": "tests",
"filePaths": [
"packages/void/test/unit/db-commands.test.ts"
],
"fileNotes": [
{
"path": "packages/void/test/unit/db-commands.test.ts",
"text": "`tableOutput()` drops blank lines because `runDbCommand` prints a leading blank line, so it only sees actual table output; the two-statement script test also reopens the database to confirm the script really ran."
}
]
},
{
"key": "docs",
"label": "Docs wording",
"summary": "Reword the `void db execute` reference to describe the new contract: row-returning statements print a table, writes are silent, and multi-statement SQL runs as a script without results.",
"category": "docs",
"filePaths": [
"docs/reference/cli/database.md"
]
}
],
"schemaVersion": 1,
"source": "llm",
"generatedAt": "2026-11-17T06:20:57.979Z",
"model": "openai-compatible/opencode-go/deepseek-v4.1-flash",
"locale": "en"
}
} |
cpojer
requested changes
Nov 17, 2026
cpojer
left a comment
Member
There was a problem hiding this comment.
two issues:
- Failed writes can execute twice because the catch block in db.ts retries through
exec. With UPDATE OR FAIL … SET count=count+1, note='a;b', a constraint failure on the second row leaves the first row incremented twice. - Scripts containing quoted comment markers fail. Two inserts where the first value is '--' fail here without inserting either row. The regex mistakes string contents for comments and hides statement separators; '/' and '/' reproduce it too. We should use SQLite’s preparation result instead.
This branch has not been deployed
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.
Fixes #862
Description
Local
void db executeprinted rows only when the SQL started withSELECT, soWITH,PRAGMA,EXPLAINandRETURNINGran and reported success with no output. The remote D1, PostgreSQL and MySQL paths already print rows for any statement that returns them.The local path now asks better-sqlite3 whether the prepared statement reads rows (
statement.reader) and prints the table when it does, instead of matching the statement text. Writes and DDL stay silent. A script with several statements still runs throughexec(), which reports no rows, and the reference docs now say so.Test
Tests in
packages/void/test/unit/db-commands.test.tsrun the local SQLite path against a real database file.WITH ... SELECT,PRAGMA database_list,EXPLAIN QUERY PLAN, aSELECTbehind a leading comment andINSERT ... RETURNINGprint a table.INSERT,CREATE TABLEand an empty result print nothing. A two-statement script runs without output, andSELECT 'a;b'stays one statement.Same command on both branches: