Skip to content

sql(sqlite): report affected row count for INSERT/UPDATE/DELETE with subquery SELECT - #30814

Closed
robobun wants to merge 1 commit into
mainfrom
farm/7cabb575/sqlite-insert-select-count
Closed

robobun wants to merge 1 commit into
mainfrom
farm/7cabb575/sqlite-insert-select-count

sql(sqlite): report affected row count for INSERT/UPDATE/DELETE with …

9aeb6be
Select commit
Loading
Failed to load commit list.
Claude / Claude Code Review completed May 22, 2026 in 15m 0s

Code review found 3 potential issues

Found 6 candidates, confirmed 3. See review comments for details.

Details

Severity Count
🔴 Important 0
🟡 Nit 3
🟣 Pre-existing 0
Severity File:Line Issue
🟡 Nit src/js/internal/sql/sqlite.ts:142 Reverse token walk still doesn't recognize backtick/bracket identifiers
🟡 Nit test/regression/issue/30811.test.ts:1-12 Test file placed in test/regression/issue/ but #30811 is not a true regression
🟡 Nit src/js/internal/sql/sqlite.ts:214-226 REPLACE INTO peek misses quoted table name with no leading space

Annotations

Check warning on line 142 in src/js/internal/sql/sqlite.ts

See this annotation in the file changed.

@claude claude / Claude Code Review

Reverse token walk still doesn't recognize backtick/bracket identifiers

Nit: CodeRabbit comment 3248701495 ("handle backtick/bracket quoting in the reverse token walk") is marked ✅ addressed in 1e32b07..1b2bc34, but only `stripSQLComments` was extended — the reverse walk's `quoted` state here is still `false | "'" | '"'` and the default arm only checks `'`/`"`. Combined with the new `sawDML` gate, a bracket/backtick identifier with internal whitespace like `[ DELETE ]` inside a `WITH … SELECT` now flushes a bare `DELETE` token, sets `sawDML`, and suppresses `canRetu

Check warning on line 12 in test/regression/issue/30811.test.ts

See this annotation in the file changed.

@claude claude / Claude Code Review

Test file placed in test/regression/issue/ but #30811 is not a true regression

Nit: per `CLAUDE.md` / `test/CLAUDE.md`, `test/regression/issue/${issueNumber}.test.ts` is reserved for true regressions (worked in a prior release, then broke) — bugs that were never correct go in the module's existing test file. The PR's own Cause section describes `parseSQLQuery`'s original design (not a later breakage), and the description even says "Four tests added in test/js/sql/sqlite-sql.test.ts". Suggest moving these into `test/js/sql/sqlite-sql.test.ts` alongside the existing INSERT/U

Check warning on line 226 in src/js/internal/sql/sqlite.ts

See this annotation in the file changed.

@claude claude / Claude Code Review

REPLACE INTO peek misses quoted table name with no leading space

Nit: the `INTO` boundary check at `text[peek + 4]` only accepts whitespace or end-of-string, but SQLite also accepts a quoted identifier immediately after `INTO` with no space — `REPLACE INTO"dst"`, ``REPLACE INTO`dst` ``, and `REPLACE INTO[dst]` are all valid. In those forms `text[peek+4]` is `"` / `` ` `` / `[`, the check fails, `sawDML` stays false, and `WITH cte AS (...) REPLACE INTO"dst" SELECT ...` still routes through `stmt.all()` → `count = 0`. Not a regression (pre-PR behaved the same),