The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →No. A successful D1 UPDATE that matches no rows does not, by itself, fail a batch or trigger rollback. Cloudflare reports whether a statement succeeded separately from how many rows it changed: a result can have success: true and meta.changes: 0.
Does a zero-row UPDATE roll back a D1 batch?
No. A zero change count is not the same as a statement error. Cloudflare’s D1 batch documentation says statements execute sequentially as one batch transaction and that a statement failure aborts or rolls back the sequence. Its return-object documentation treats success and meta.changes as separate fields, including an example where success is true and changes is zero.
As an Amazon Associate I earn from qualifying purchases.
| Case | Statement result | Batch outcome | Earlier writes |
|---|---|---|---|
| UPDATE executes successfully but matches no rows | success: true; meta.changes: 0 is possible |
Zero changes alone are not a documented failure trigger | Not rolled back merely because the UPDATE changed zero rows |
| A statement produces a SQL execution error | The failing statement returns an error | The batch sequence aborts or rolls back | Writes earlier in the sequence are rolled back under the documented batch behavior |
Cloudflare’s documented boundary is statement failure, not a minimum affected-row count. The API documentation does not describe a setting that automatically turns meta.changes === 0 into an error.
How to test the rollback boundary
Use a deterministic database fixture and keep the two behaviors in separate assertions. Batch results correspond to their prepared statements in input order, so inspect the result associated with the no-match UPDATE.
#1 Best Overall
- Set a known initial state. Create or reset fixture rows so the expected outcome is unambiguous.
- Test the zero-match case. Prepare an UPDATE whose
WHEREcondition matches no rows and include it in a batch with a harmless statement. Assert that the UPDATE result indicates success and that itsmeta.changesvalue is zero. - Test actual failure separately. Reset the fixture, place a valid write before a statement designed to produce a genuine SQL error, and run them in a batch.
- Check both failure and persistence. Assert that the batch reports the error, then query the fixture to verify that the earlier write did not persist.
This structure distinguishes a successful statement with no matching rows from a statement that fails to execute. It follows Cloudflare’s documented contract; the assertions are a test plan, not a report of a test run.
What if the application requires exactly one row?
If changing exactly one row is a business requirement, enforce it in application logic: inspect the relevant result’s change count and explicitly throw an error or handle the mismatch when it is not one. That application-level policy is separate from D1’s documented batch behavior; a zero count does not automatically become a batch failure.
Rank #2
Documentation date and historical caveat
Cloudflare’s D1 Database API page was last updated June 22, 2026, and its Return objects page was last updated September 17, 2026. An archived Miniflare issue from January 29, 2023 discussed a local-development rollback concern with Wrangler v2.8.1; it is historical context, not evidence that current D1 batches treat zero changed rows as a failure.
Quick Recap
Rank #4
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




