From: Robert Bohne Date: Tue, 19 Jul 2011 12:32:00 +0000 (+0200) Subject: Handle on_delete => 'restrict' in Producer::Oracle X-Git-Tag: v0.11011~73 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0d3badf1ba563e8a7f138b7d68848800b11a8b26;p=dbsrgits%2FSQL-Translator.git Handle on_delete => 'restrict' in Producer::Oracle --- diff --git a/Changes b/Changes index 0b96a40..166246a 100644 --- a/Changes +++ b/Changes @@ -5,6 +5,8 @@ via alter_field to a column in Postgres Producer * added a working mechanism for naming foreign keys in the PostgreSQL producer * Fix possible name duplication in SQLlite producer +* Oracle does not accept ON DELETE/UPDATE RESTRICT (though it is the actual default) + fix by not adding the ON DELETE/UPDATE clause at all # ---------------------------------------------------------- # 0.11010 2011-10-05 diff --git a/lib/SQL/Translator/Producer/Oracle.pm b/lib/SQL/Translator/Producer/Oracle.pm index 4bc2a94..b2726a0 100644 --- a/lib/SQL/Translator/Producer/Oracle.pm +++ b/lib/SQL/Translator/Producer/Oracle.pm @@ -380,6 +380,8 @@ sub create_table { elsif ( $c->type eq FOREIGN_KEY ) { $name = mk_name( join('_', $table_name, $c->fields). '_fk' ); $name = quote($name, $qf); + my $on_delete = uc ($c->on_delete || ''); + my $def = "CONSTRAINT $name FOREIGN KEY "; if ( @fields ) { @@ -399,7 +401,7 @@ sub create_table { ( $c->match_type =~ /full/i ) ? 'FULL' : 'PARTIAL'; } - if ( $c->on_delete ) { + if ( $on_delete && $on_delete ne "RESTRICT") { $def .= ' ON DELETE '.$c->on_delete; }