Skip to content

[13.x] Fix restore() failing on soft delete queries with joins - #61998

Merged
taylorotwell merged 1 commit into
laravel:13.xfrom
xurshudyan:soft-delete-restore-with-joins
Oct 14, 2026
Merged

taylorotwell merged 1 commit into
laravel:13.xfrom
xurshudyan:soft-delete-restore-with-joins

Conversation

@xurshudyan

Copy link
Copy Markdown
Contributor

restore() fails on MySQL when the query has a join to another table that also has a deleted_at column, for example a hasManyThrough relation where both models use SoftDeletes:

$team->posts()->delete(); // works

$team->posts()->onlyTrashed()->restore();
// SQLSTATE[23000]: 1052 Column 'deleted_at' in field list is ambiguous

@taylorotwell
taylorotwell merged commit ce7a0de into laravel:13.x Oct 14, 2026
64 checks passed
albertcht pushed a commit to hypervel/database that referenced this pull request Oct 31, 2026
Port laravel/framework#61998 (ce7a0de5aed01ed1e45791a78def2343e6a33abc).

Use the existing join-aware deleted-column lookup for restore, matching delete and avoiding ambiguous columns when the joined model also uses soft deletes.

Port the through-parent restore regression and fixtures. Complete through-relation and soft-delete scope tests pass. The regression reproduces the prior ambiguous-column failure on MySQL and passes with the fix.
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.

2 participants