Skip to content

Add built-in soft delete support - #340

Open
elpete wants to merge 1 commit into
nextfrom
feat/54-soft-deletes
Open

Add built-in soft delete support#340
elpete wants to merge 1 commit into
nextfrom
feat/54-soft-deletes

Conversation

@elpete

@elpete elpete commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator

Closes #54

Issue review

Recommendation: 9/10 — implement. Soft deletes are common enough that every application should not have to rebuild the same global scope and lifecycle methods. A metadata-driven implementation fits Quick’s entity model. The tradeoffs are an additional nullable timestamp column, behavior changes for delete/deleteAll on opted-in entities, and the need to choose permanent deletion explicitly.

Implementation

Configure an entity with softDeletes=true, optionally set softDeleteColumn (default deletedAt), and define that property. The feature adds:

  • default exclusion of soft-deleted rows
  • withTrashed() and onlyTrashed() query controls
  • entity delete(), restore(), trashed(), and forceDelete() behavior
  • bulk deleteAll(), restoreAll(), and forceDeleteAll() behavior
  • validation that the configured soft-delete attribute exists
  • preserved pre/post delete events for normal and soft deletes

Test-first evidence

The end-to-end public regression initially failed because delete() permanently removed the entity and marked it unloaded. It now covers default visibility, querying trashed rows, restoring, soft bulk deletion/restoration, and permanent entity/bulk deletion.

The first full suite exposed two missing post-delete event assertions after the delete refactor; those were fixed before opening this PR.

Validation

  • focused soft-delete and delete-event specs: 5 passed, 0 failed, 0 errors
  • full Lucee 6 suite: 496 passed, 0 failed, 0 errors, 3 skipped
  • box run-script format
  • git diff --check

Uses qb@14.0.0-beta.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant