-
Notifications
You must be signed in to change notification settings - Fork 48
Open
Description
I'm planning on working this until I have a proposed patch, but wanted to give a heads up and see if you had any advice.
Here's my reproduction case in my own codebase: (TP_TradeEstimate and Hours are both subclasses of the same thing)
public function testOnlyTrashedShouldntBreakSingleTableInheritance(): void
{
$liveTP = TP_TradeEstimate::factory()->create();
$deletedTP = TP_TradeEstimate::factory()->create();
$deletedTP->delete();
$liveOther = Hours::factory()->create();
$deletedOther = Hours::factory()->create();
$deletedOther->delete();
self::assertSame(1, TP_TradeEstimate::onlyTrashed()->count());
$affectedRows = TP_TradeEstimate::onlyTrashed()->forceDelete();
self::assertSame(1, $affectedRows, 'Affected rows should match counted rows');
self::assertModelExists($liveTP);
self::assertFalse(
DB::table('account_integrations')
->where('id', $deletedTP->id)
->exists(),
);
self::assertModelExists($liveOther);
self::assertSoftDeleted($deletedOther);
}
This fails because $affectedRows is actually 2, and if you comment out that assertion, the last assertion fails because $deletedOther has been forceDeleted. Even weirder, obviously onlyTrashed by itself isn't the problem, that count works, and if you get() the collection and do each->forceDelete() there's no problem.
Using single-table-inheritance v1.0.0 with Laravel framework 9.36.2
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels