Skip to content

2.0.0-next.25

Pre-release
Pre-release

Choose a tag to compare

@3m1n3nc3 3m1n3nc3 released this 18 Apr 17:35

What's Changed

Fix query delete behavior when no rows match

QueryBuilder.delete() no longer throws when a constrained delete finds no matching row. It now returns null, which fixes cases like User.query().whereNot({ id: demoUser.id }).delete() behaving as an unexpected failure instead of a no-op.

Add explicit throwing delete variant

Added QueryBuilder.deleteOrFail() for callers that need the previous fail-fast behavior. This preserves a strict path for workflows that expect a deleted model instance or an error.

Keep model instance deletes strict

Model.delete() and Model.forceDelete() now delegate to deleteOrFail(), so deleting a concrete model instance still throws if the underlying row cannot be found. The nullable behavior is limited to query-builder deletes.

Add regression coverage

Added base and Postgres query-builder tests covering:

  • non-unique constrained deletes that match no rows now returning null
  • row-count stability when the delete is a no-op
  • deleteOrFail() continuing to throw Record not found for delete operation.

Full Changelog: 2.0.0-next.23...2.0.0-next.25