[Dbix-class] Cascade deletes
Moritz Onken
onken at houseofdesign.de
Sat Mar 6 12:12:13 GMT 2010
>
>> I notice that DBIC does a select to find the related rows (i.e. in the
>> Cd table when looking for rows to cascade delete). Is there a reason
>> that's done instead of just deleting directly?
>>
>> INSERT INTO artist ( label, name) VALUES ( ?, ? ): '1', 'test aritst'
>> INSERT INTO cd ( artist) VALUES ( ? ): '25'
>>
>> DELETE FROM artist WHERE ( id = ? ): '25'
>> SELECT me.id <http://me.id>, me.year, me.name <http://me.name>,
>> me.artist FROM cd me WHERE ( me.artist = ? ): '25'
>> DELETE FROM cd WHERE ( id = ? ): '54'
>>
>> Why not just delete from cd where artist = 25?
>> Again, sure seems like that should be inside a transaction.
>
> Correct, fix on TODO list.
And shouldn't that be a SELECT ... FOR UPDATE before the delete?
I am still trying to figure this whole transaction/locking/update
stuff out.
cheers,
moritz
More information about the DBIx-Class
mailing list