Skip to content

feat(mysql): ORDER BY and LIMIT on single-table UPDATE and DELETE - #154

Merged
Makisuo merged 4 commits into
mainfrom
t3/mysql-write-limit
Nov 25, 2026
Merged

Makisuo merged 4 commits into
mainfrom
t3/mysql-write-limit

test(docs): the chunked DELETE example writes its limit as a literal

c93fa1f
Select commit
Loading
Failed to load commit list.
Maple Review Bot / Maple / review succeeded Nov 25, 2026 in 3m 3s

Confidence 10/10 · No issues found

🟢 Confidence 10/10 · safe to merge. Clause rendering, dialect gating, limit validation and tenant scope are pinned by compile, type and live MySQL tests; only the two open info items (message wording, stale JSDoc) remain.
2 notes · tests covered · risk medium

Adds MySQL/MariaDB ORDER BY/LIMIT to single-table UPDATE and DELETE, gated to the mysql clause set and rendered after the WHERE, with the limit a validated literal. Logic, gating and the doc-example fix hold up; only the two open info notes stand.

  • orderBy/limit on deleteFrom/update write MySQL's single-table ORDER BY ... LIMIT
  • WriteLimitClause refuses the pair on Postgres, SQLite and ClickHouse, and with UPDATE ... FROM
  • A write's limit renders as a literal through rowCount, so no param name can stand in
  • ORDER BY subqueries are recorded, widening a write's tenant scope

Still open from earlier reviews

  • 🔵 Note · F1 · UPDATE ... FROM refusal names orderBy() even when only limit() was set · src/ch/compile.ts:2660
  • 🔵 Note · F3 · limit JSDoc says the count is bound as a parameter; it is a literal · src/ch/update.ts:189
What was checked
  • MariaDB inherits the clause by spreading mysqlDialect (src/mysql/dialect.ts:148), so the type and run-time gates agree
  • limit(undefined) is told apart from an absent limit via Object.hasOwn, and the initial write state carries no limitValue key (src/ch/update.ts:359)
  • ORDER BY/LIMIT compile after the SET and WHERE, matching their textual position, so parameter order is unchanged (src/ch/compile.ts:2703)

c93fa1f · Reply "won't fix" to dismiss a finding, or mention @maple-review-bot to ask about one.