[Dbix-class] Deletion of related rows in MySQL

Peter Rabbitson rabbit+dbic at rabbit.us
Tue Apr 9 09:12:17 GMT 2013


On Tue, Apr 09, 2013 at 01:00:56PM +0400, Konstantin A. Pustovalov wrote:
> 09.04.2013 12:51, Peter Rabbitson ?????:
> >On Tue, Apr 09, 2013 at 12:35:04PM +0400, Konstantin A. Pustovalov wrote:
> >>Hi list!
> >>
> >>I have a code which I have narrowed to http://paste.scsys.co.uk/240549
> >>It does $schema->resultset->search_rs->search_related_rs->delete
> >>This happened to work with DBIC v 0.08196 but stopped after upgrade
> >>to recent version.
> >Which recent version? I ask because this very issue was re-fixed in
> >0.08205 [1] which shipped 3 month ago.
> >
> >Please let me know if you observe the same problem under the current
> >version 0.08210, and if this is the case - augment t/71mysql.t [2] with
> >a scenario modeled on the failure you encountered.
> >
> yes, the recent version is 0.08210 (I have stated that in previous message)

Missed that sorry. I *think* I see the issue. Can you please try this
preliminary fix and report back.

Cheers

diff --git a/lib/DBIx/Class/Storage/DBI/mysql.pm b/lib/DBIx/Class/Storage/DBI/mysql.pm
index 3ace8e2..a2aa2fc 100644
--- a/lib/DBIx/Class/Storage/DBI/mysql.pm
+++ b/lib/DBIx/Class/Storage/DBI/mysql.pm
@@ -78,7 +78,7 @@ sub _prep_for_execute {
   }
 
   local $sm->{_modification_target_referenced_re} =
-      qr/ (?<!DELETE) [\s\)] FROM \s (?: \` \Q$target_name\E \` | \Q$target_name\E ) [\s\(] /xi
+      qr/ (?<!DELETE) [\s\)] (?: FROM | JOIN ) \s (?: \` \Q$target_name\E \` | \Q$target_name\E ) [\s\(] /xi
     if $target_name;
 
   $self->next::method(@_);




More information about the DBIx-Class mailing list