[Dbix-class] ON DELETE statement in Pg not avaiable in schema::loader?

Moritz Onken onken at houseofdesign.de
Mon Mar 24 17:49:48 GMT 2008

Am 21.03.2008 um 17:43 schrieb Matt S Trout:
> On Sat, Mar 08, 2008 at 06:11:22PM +0100, Moritz Onken wrote:
>> Wouldn't it be great (tm) if we could add an "on_delete" and
>> "on_update" config
>> to all the relationships? Like the "cascade_delete" config option.
>> If the DMBS supports that type of actions DBIC does not have to take
>> care of it,
>> otherwise it does.
> Seems reasonable, but how well can we abstract it to be non-db- 
> specific?
> If we can't, I think just using sqlt_deploy_hook is the answer.

I'd like to push this a little bit because I think it could be really  
helpful. For now I applied a patch to the current 0.09 trunk which  
allow to set on_delete and on_update on a relationship. This will not  
break backwards comp. but generates the correct ouput if you use SQLT.

What do you think about a config option which tells DBIC to not handle  
the trigger actions (on_delete on_update resp. cascade_delete)? If  
this is set the DBMS is to handle those operations which will result  
in a significant speed increase.
If this config option is not set DBIC is to handle all those actions  

This way it's still independent from the DBMS.

I just want to know if you guys think if this is useful and I'll try  
to write patches and so on.



Index: /Users/mo/Documents/workspace/DBIx-Class/lib/SQL/Translator/ 
--- /Users/mo/Documents/workspace/DBIx-Class/lib/SQL/Translator/Parser/ 
DBIx/Class.pm	(revision 4223)
+++ /Users/mo/Documents/workspace/DBIx-Class/lib/SQL/Translator/Parser/ 
DBIx/Class.pm	(working copy)
@@ -135,6 +135,8 @@
                  my $on_update = '';

                  if (defined $otherrelationship) {
+                    $on_delete = $otherrelationship->{'attrs'}- 
 >{on_delete} || '';
+                    $on_update = $otherrelationship->{'attrs'}- 
 >{on_update} || '';
                      $on_delete = $otherrelationship->{'attrs'}- 
 >{cascade_delete} ? 'CASCADE' : '';
                      $on_update = $otherrelationship->{'attrs'}- 
 >{cascade_copy} ? 'CASCADE' : '';

More information about the DBIx-Class mailing list