I found an issue, when a SoftDeleted model should delete a NotSoftDeleted model. The CascadeQueryListener triggers an update, and tries to update the deleted_at-columns, which does only exist, if the model uses SoftDeletes.
My use-case is an edge-case, but still valid, I think. I have this model structure:
Group(SoftDeleted) > Device(SoftDeleted) > Logs
Logs are not SoftDeleted, as they are very short-lived anyway. They have no SoftDelete, and are lost if the Device is deleted. This works without issues.
If the Group is deleted, it does CascadeDelete the Device, which then should CascadeDelete the Logs (hard delete). But this triggers also an update() somewhere, and because updated query withTrashed(), the transaction fails.
With this rather quick fix, withTrashed() should only be called if the model is SoftDeletable.
I found an issue, when a SoftDeleted model should delete a NotSoftDeleted model. The
CascadeQueryListener
triggers an update, and tries to update thedeleted_at
-columns, which does only exist, if the model uses SoftDeletes.My use-case is an edge-case, but still valid, I think. I have this model structure:
Logs are not SoftDeleted, as they are very short-lived anyway. They have no SoftDelete, and are lost if the Device is deleted. This works without issues.
If the Group is deleted, it does CascadeDelete the Device, which then should CascadeDelete the Logs (hard delete). But this triggers also an
update()
somewhere, and because updated querywithTrashed()
, the transaction fails.With this rather quick fix,
withTrashed()
should only be called if the model is SoftDeletable.