Skip to content

Commit e8ded4b

Browse files
committed
fix(cli): fail a row delete that matched nothing
`tables rows batch-delete` exited 0 when none of the named rows existed, while the table equivalent exited 1 on the same shape. Only the id-list selection is checked: a filter answers without a requested count, so the guard self-excludes and an idempotent sweep still exits 0 on its second run.
1 parent 0a885f7 commit e8ded4b

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

packages/sim-cli/src/runtime/execute.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,19 @@ export const BULK_OUTCOME_CHECKS: Readonly<Partial<Record<V2OperationName, BulkO
129129
? safeOneLine(reported)
130130
: `Updated nothing: none of the ${requested} requested ${requested === 1 ? 'chunk' : 'chunks'} matched.`
131131
},
132+
/**
133+
* Only the id-list selection is checked. The filter branch answers with a
134+
* deleted count alone — no `requestedCount` — so the guard below self-excludes
135+
* on it, which is right: a filter matching nothing deleted nothing because
136+
* there was nothing to delete, and failing there would break the second run of
137+
* an otherwise idempotent sweep.
138+
*/
139+
deleteTableRows: (payload) => {
140+
if (countOf(payload.deletedCount) > 0) return null
141+
const requested = countOf(payload.requestedCount)
142+
if (requested === 0) return null
143+
return `Deleted nothing: none of the ${requested} requested ${requested === 1 ? 'row was' : 'rows were'} deleted.`
144+
},
132145
moveTables: (payload) => {
133146
if (lengthOf(payload.moved) > 0) return null
134147
const missed = lengthOf(payload.notFound) + lengthOf(payload.failed)

0 commit comments

Comments
 (0)