From: Ben Faga Date: Tue, 28 Jun 2005 16:39:41 +0000 (+0000) Subject: Changed references to on_delete_do to on_delete and on_update_do to on_update. I... X-Git-Tag: v0.11008~518 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=100684f30c51373737c7f4792a6c0bc465e559a6;p=dbsrgits%2FSQL-Translator.git Changed references to on_delete_do to on_delete and on_update_do to on_update. I tried to keep it backwards compatible. --- diff --git a/lib/SQL/Translator/Parser/Access.pm b/lib/SQL/Translator/Parser/Access.pm index b243ca8..bcbb9ee 100644 --- a/lib/SQL/Translator/Parser/Access.pm +++ b/lib/SQL/Translator/Parser/Access.pm @@ -1,7 +1,7 @@ package SQL::Translator::Parser::Access; # ------------------------------------------------------------------- -# $Id: Access.pm,v 1.2 2004-07-30 21:56:18 kycl4rk Exp $ +# $Id: Access.pm,v 1.3 2005-06-28 16:39:41 mwz444 Exp $ # ------------------------------------------------------------------- # Copyright (C) 2002-4 SQLFairy Authors # @@ -41,7 +41,7 @@ something similar to the output of mdbtools (http://mdbtools.sourceforge.net/). use strict; use vars qw[ $DEBUG $VERSION $GRAMMAR @EXPORT_OK ]; -$VERSION = sprintf "%d.%02d", q$Revision: 1.2 $ =~ /(\d+)\.(\d+)/; +$VERSION = sprintf "%d.%02d", q$Revision: 1.3 $ =~ /(\d+)\.(\d+)/; $DEBUG = 0 unless defined $DEBUG; use Data::Dumper; @@ -211,15 +211,15 @@ field_qualifier : /character set/i WORD } } -reference_definition : /references/i table_name parens_field_list(?) match_type(?) on_delete_do(?) on_update_do(?) +reference_definition : /references/i table_name parens_field_list(?) match_type(?) on_delete(?) on_update(?) { $return = { type => 'foreign_key', reference_table => $item[2], reference_fields => $item[3][0], match_type => $item[4][0], - on_delete_do => $item[5][0], - on_update_do => $item[6][0], + on_delete => $item[5][0], + on_update => $item[6][0], } } @@ -227,10 +227,10 @@ match_type : /match full/i { 'full' } | /match partial/i { 'partial' } -on_delete_do : /on delete/i reference_option +on_delete : /on delete/i reference_option { $item[2] } -on_update_do : /on update/i reference_option +on_update : /on update/i reference_option { $item[2] } reference_option: /restrict/i | diff --git a/lib/SQL/Translator/Parser/DB2.pm b/lib/SQL/Translator/Parser/DB2.pm index 8a89f37..55032dc 100644 --- a/lib/SQL/Translator/Parser/DB2.pm +++ b/lib/SQL/Translator/Parser/DB2.pm @@ -79,8 +79,8 @@ sub parse { reference_table => $cdata->{'reference_table'}, reference_fields => $cdata->{'reference_fields'}, match_type => $cdata->{'match_type'} || '', - on_delete => $cdata->{'on_delete_do'}, - on_update => $cdata->{'on_update_do'}, + on_delete => $cdata->{'on_delete'} || $cdata->{'on_delete_do'}, + on_update => $cdata->{'on_update'} || $cdata->{'on_update_do'}, ) or die $table->error; } } diff --git a/lib/SQL/Translator/Parser/MySQL.pm b/lib/SQL/Translator/Parser/MySQL.pm index 5dd77ff..5d4a4d1 100644 --- a/lib/SQL/Translator/Parser/MySQL.pm +++ b/lib/SQL/Translator/Parser/MySQL.pm @@ -1,7 +1,7 @@ package SQL::Translator::Parser::MySQL; # ------------------------------------------------------------------- -# $Id: MySQL.pm,v 1.49 2005-06-27 20:36:42 duality72 Exp $ +# $Id: MySQL.pm,v 1.50 2005-06-28 16:39:41 mwz444 Exp $ # ------------------------------------------------------------------- # Copyright (C) 2002-4 SQLFairy Authors # @@ -134,7 +134,7 @@ A subset of INSERT that we ignore: use strict; use vars qw[ $DEBUG $VERSION $GRAMMAR @EXPORT_OK ]; -$VERSION = sprintf "%d.%02d", q$Revision: 1.49 $ =~ /(\d+)\.(\d+)/; +$VERSION = sprintf "%d.%02d", q$Revision: 1.50 $ =~ /(\d+)\.(\d+)/; $DEBUG = 0 unless defined $DEBUG; use Data::Dumper; @@ -315,7 +315,7 @@ field_comment2 : /comment/i /'.*?'/ blank : /\s*/ -field : field_comment(s?) field_name data_type field_qualifier(s?) field_comment2(?) reference_definition(?) on_update_do(?) field_comment(s?) +field : field_comment(s?) field_name data_type field_qualifier(s?) field_comment2(?) reference_definition(?) on_update(?) field_comment(s?) { my %qualifiers = map { %$_ } @{ $item{'field_qualifier(s?)'} || [] }; if ( my @type_quals = @{ $item{'data_type'}{'qualifiers'} || [] } ) { @@ -398,15 +398,15 @@ field_qualifier : /on update/i CURRENT_TIMESTAMP } } -reference_definition : /references/i table_name parens_field_list(?) match_type(?) on_delete_do(?) on_update_do(?) +reference_definition : /references/i table_name parens_field_list(?) match_type(?) on_delete(?) on_update(?) { $return = { type => 'foreign_key', reference_table => $item[2], reference_fields => $item[3][0], match_type => $item[4][0], - on_delete_do => $item[5][0], - on_update_do => $item[6][0], + on_delete => $item[5][0], + on_update => $item[6][0], } } @@ -414,10 +414,10 @@ match_type : /match full/i { 'full' } | /match partial/i { 'partial' } -on_delete_do : /on delete/i reference_option +on_delete : /on delete/i reference_option { $item[2] } -on_update_do : +on_update : /on update/i 'CURRENT_TIMESTAMP' { $item[2] } | @@ -777,8 +777,8 @@ sub parse { reference_table => $cdata->{'reference_table'}, reference_fields => $cdata->{'reference_fields'}, match_type => $cdata->{'match_type'} || '', - on_delete => $cdata->{'on_delete_do'}, - on_update => $cdata->{'on_update_do'}, + on_delete => $cdata->{'on_delete'} || $cdata->{'on_delete_do'}, + on_update => $cdata->{'on_update'} || $cdata->{'on_update_do'}, ) or die $table->error; } } diff --git a/lib/SQL/Translator/Parser/Oracle.pm b/lib/SQL/Translator/Parser/Oracle.pm index e2800dd..9868d08 100644 --- a/lib/SQL/Translator/Parser/Oracle.pm +++ b/lib/SQL/Translator/Parser/Oracle.pm @@ -1,7 +1,7 @@ package SQL::Translator::Parser::Oracle; # ------------------------------------------------------------------- -# $Id: Oracle.pm,v 1.19 2004-09-17 21:52:46 kycl4rk Exp $ +# $Id: Oracle.pm,v 1.20 2005-06-28 16:39:41 mwz444 Exp $ # ------------------------------------------------------------------- # Copyright (C) 2002-4 SQLFairy Authors # @@ -97,7 +97,7 @@ was altered to better handle the syntax created by DDL::Oracle. use strict; use vars qw[ $DEBUG $VERSION $GRAMMAR @EXPORT_OK ]; -$VERSION = sprintf "%d.%02d", q$Revision: 1.19 $ =~ /(\d+)\.(\d+)/; +$VERSION = sprintf "%d.%02d", q$Revision: 1.20 $ =~ /(\d+)\.(\d+)/; $DEBUG = 0 unless defined $DEBUG; use Data::Dumper; @@ -343,7 +343,7 @@ column_constraint : constraint_name(?) column_constraint_type reference_table => $desc->{'reference_table'}, reference_fields => $desc->{'reference_fields'}, # match_type => $desc->{'match_type'}, -# on_update_do => $desc->{'on_update_do'}, +# on_update => $desc->{'on_update'}, } } @@ -358,14 +358,14 @@ column_constraint_type : /not\s+null/i { $return = { type => 'not_null' } } { $return = { type => 'primary_key' } } | /check/i '(' /[^)]+/ ')' { $return = { type => 'check', expression => $item[3] } } - | /references/i table_name parens_word_list(?) on_delete_do(?) + | /references/i table_name parens_word_list(?) on_delete(?) { $return = { type => 'foreign_key', reference_table => $item[2], reference_fields => $item[3][0], # match_type => $item[4][0], - on_delete_do => $item[5][0], + on_delete => $item[5][0], } } @@ -470,8 +470,8 @@ table_constraint : comment(s?) constraint_name(?) table_constraint_type deferrab reference_table => $desc->{'reference_table'}, reference_fields => $desc->{'reference_fields'}, # match_type => $desc->{'match_type'}[0], - on_delete_do => $desc->{'on_delete_do'}, - on_update_do => $desc->{'on_update_do'}, + on_delete => $desc->{'on_delete'} || $desc->{'on_delete_do'}, + on_update => $desc->{'on_update'} || $desc->{'on_update_do'}, comments => [ @comments ], } } @@ -500,7 +500,7 @@ table_constraint_type : /primary key/i '(' NAME(s /,/) ')' } } | - /foreign key/i '(' NAME(s /,/) ')' /references/i table_name parens_word_list(?) on_delete_do(?) + /foreign key/i '(' NAME(s /,/) ')' /references/i table_name parens_word_list(?) on_delete(?) { $return = { type => 'foreign_key', @@ -508,12 +508,12 @@ table_constraint_type : /primary key/i '(' NAME(s /,/) ')' reference_table => $item[6], reference_fields => $item[7][0], match_type => $item[8][0], - on_delete_do => $item[9][0], - on_update_do => $item[10][0], + on_delete => $item[9][0], + on_update => $item[10][0], } } -on_delete_do : /on delete/i WORD(s) +on_delete : /on delete/i WORD(s) { $item[2] } UNIQUE : /unique/i { $return = 1 } @@ -610,8 +610,8 @@ sub parse { reference_table => $cdata->{'reference_table'}, reference_fields => $cdata->{'reference_fields'}, match_type => $cdata->{'match_type'} || '', - on_delete => $cdata->{'on_delete_do'}, - on_update => $cdata->{'on_update_do'}, + on_delete => $cdata->{'on_delete'} || $cdata->{'on_delete_do'}, + on_update => $cdata->{'on_update'} || $cdata->{'on_update_do'}, ) or die $table->error; } } diff --git a/lib/SQL/Translator/Parser/PostgreSQL.pm b/lib/SQL/Translator/Parser/PostgreSQL.pm index 14ceff1..a76d704 100644 --- a/lib/SQL/Translator/Parser/PostgreSQL.pm +++ b/lib/SQL/Translator/Parser/PostgreSQL.pm @@ -1,7 +1,7 @@ package SQL::Translator::Parser::PostgreSQL; # ------------------------------------------------------------------- -# $Id: PostgreSQL.pm,v 1.43 2004-10-23 20:18:44 cmungall Exp $ +# $Id: PostgreSQL.pm,v 1.44 2005-06-28 16:39:41 mwz444 Exp $ # ------------------------------------------------------------------- # Copyright (C) 2002-4 SQLFairy Authors # @@ -108,7 +108,7 @@ View table: use strict; use vars qw[ $DEBUG $VERSION $GRAMMAR @EXPORT_OK ]; -$VERSION = sprintf "%d.%02d", q$Revision: 1.43 $ =~ /(\d+)\.(\d+)/; +$VERSION = sprintf "%d.%02d", q$Revision: 1.44 $ =~ /(\d+)\.(\d+)/; $DEBUG = 0 unless defined $DEBUG; use Data::Dumper; @@ -394,8 +394,8 @@ column_constraint : constraint_name(?) column_constraint_type deferrable(?) defe reference_table => $desc->{'reference_table'}, reference_fields => $desc->{'reference_fields'}, match_type => $desc->{'match_type'}, - on_delete_do => $desc->{'on_delete_do'}, - on_update_do => $desc->{'on_update_do'}, + on_delete => $desc->{'on_delete'} || $desc->{'on_delete_do'}, + on_update => $desc->{'on_update'} || $desc->{'on_update_do'}, } } @@ -428,8 +428,8 @@ column_constraint_type : /not null/i { $return = { type => 'not_null' } } reference_table => $item[2], reference_fields => $item[3][0], match_type => $item[4][0], - on_delete_do => $on_delete, - on_update_do => $on_update, + on_delete => $on_delete, + on_update => $on_update, } } @@ -601,8 +601,8 @@ table_constraint : comment(s?) constraint_name(?) table_constraint_type deferrab reference_table => $desc->{'reference_table'}, reference_fields => $desc->{'reference_fields'}, match_type => $desc->{'match_type'}[0], - on_delete_do => $desc->{'on_delete_do'}, - on_update_do => $desc->{'on_update_do'}, + on_delete => $desc->{'on_delete'} || $desc->{'on_delete_do'}, + on_update => $desc->{'on_update'} || $desc->{'on_update_do'}, comments => [ @comments ], } } @@ -646,8 +646,8 @@ table_constraint_type : /primary key/i '(' name_with_opt_quotes(s /,/) ')' reference_table => $item[6], reference_fields => $item[7][0], match_type => $item[8][0], - on_delete_do => $on_delete || '', - on_update_do => $on_update || '', + on_delete => $on_delete || '', + on_update => $on_update || '', } } @@ -979,8 +979,8 @@ sub parse { reference_table => $cdata->{'reference_table'}, reference_fields => $cdata->{'reference_fields'}, match_type => $cdata->{'match_type'} || '', - on_delete => $cdata->{'on_delete_do'}, - on_update => $cdata->{'on_update_do'}, + on_delete => $cdata->{'on_delete'} || $cdata->{'on_delete_do'}, + on_update => $cdata->{'on_update'} || $cdata->{'on_update_do'}, expression => $cdata->{'expression'}, ) or die "Can't add constraint of type '" . $cdata->{'type'} . "' to table '" . $table->name . diff --git a/lib/SQL/Translator/Parser/SQLServer.pm b/lib/SQL/Translator/Parser/SQLServer.pm index e97f4c2..4d95e04 100644 --- a/lib/SQL/Translator/Parser/SQLServer.pm +++ b/lib/SQL/Translator/Parser/SQLServer.pm @@ -1,7 +1,7 @@ package SQL::Translator::Parser::SQLServer; # ------------------------------------------------------------------- -# $Id: SQLServer.pm,v 1.1 2005-06-27 19:01:31 duality72 Exp $ +# $Id: SQLServer.pm,v 1.2 2005-06-28 16:39:41 mwz444 Exp $ # ------------------------------------------------------------------- # Copyright (C) 2002-4 SQLFairy Authors # @@ -39,7 +39,7 @@ should probably be considered a work in progress. use strict; use vars qw[ $DEBUG $VERSION $GRAMMAR @EXPORT_OK ]; -$VERSION = sprintf "%d.%02d", q$Revision: 1.1 $ =~ /(\d+)\.(\d+)/; +$VERSION = sprintf "%d.%02d", q$Revision: 1.2 $ =~ /(\d+)\.(\d+)/; $DEBUG = 0 unless defined $DEBUG; use Data::Dumper; @@ -283,7 +283,7 @@ primary_key_constraint : /constraint/i index_name(?) /primary/i /key/i parens_fi } } -foreign_key_constraint : /constraint/i index_name(?) /foreign/i /key/i parens_field_list /references/i table_name parens_field_list(?) on_delete_do(?) on_update_do(?) +foreign_key_constraint : /constraint/i index_name(?) /foreign/i /key/i parens_field_list /references/i table_name parens_field_list(?) on_delete(?) on_update(?) { $return = { supertype => 'constraint', @@ -292,8 +292,8 @@ foreign_key_constraint : /constraint/i index_name(?) /foreign/i /key/i parens_fi fields => $item[5], reference_table => $item[7], reference_fields => $item[8][0], - on_delete_do => $item[9][0], - on_update_do => $item[10][0], + on_delete => $item[9][0], + on_update => $item[10][0], } } @@ -309,10 +309,10 @@ unique_constraint : /unique/i clustered(?) INDEX(?) index_name(?) on_table(?) pa } } -on_delete_do : /on delete/i reference_option +on_delete : /on delete/i reference_option { $item[2] } -on_update_do : /on update/i reference_option +on_update : /on update/i reference_option { $item[2] } reference_option: /cascade/i | @@ -455,8 +455,8 @@ sub parse { reference_table => $cdata->{'reference_table'}, reference_fields => $cdata->{'reference_fields'}, match_type => $cdata->{'match_type'} || '', - on_delete => $cdata->{'on_delete_do'}, - on_update => $cdata->{'on_update_do'}, + on_delete => $cdata->{'on_delete'} || $cdata->{'on_delete_do'}, + on_update => $cdata->{'on_update'} || $cdata->{'on_update_do'}, ) or die $table->error; } } diff --git a/lib/SQL/Translator/Parser/SQLite.pm b/lib/SQL/Translator/Parser/SQLite.pm index 4f2f12b..0ffc472 100644 --- a/lib/SQL/Translator/Parser/SQLite.pm +++ b/lib/SQL/Translator/Parser/SQLite.pm @@ -1,7 +1,7 @@ package SQL::Translator::Parser::SQLite; # ------------------------------------------------------------------- -# $Id: SQLite.pm,v 1.6 2004-02-09 22:23:40 kycl4rk Exp $ +# $Id: SQLite.pm,v 1.7 2005-06-28 16:39:41 mwz444 Exp $ # ------------------------------------------------------------------- # Copyright (C) 2002-4 SQLFairy Authors # @@ -152,7 +152,7 @@ like-op::= use strict; use vars qw[ $DEBUG $VERSION $GRAMMAR @EXPORT_OK ]; -$VERSION = sprintf "%d.%02d", q$Revision: 1.6 $ =~ /(\d+)\.(\d+)/; +$VERSION = sprintf "%d.%02d", q$Revision: 1.7 $ =~ /(\d+)\.(\d+)/; $DEBUG = 0 unless defined $DEBUG; use Data::Dumper; @@ -604,8 +604,8 @@ sub parse { reference_table => $cdata->{'reference_table'}, reference_fields => $cdata->{'reference_fields'}, match_type => $cdata->{'match_type'} || '', - on_delete => $cdata->{'on_delete_do'}, - on_update => $cdata->{'on_update_do'}, + on_delete => $cdata->{'on_delete'} || $cdata->{'on_delete_do'}, + on_update => $cdata->{'on_update'} || $cdata->{'on_update_do'}, ) or die $table->error; } } diff --git a/lib/SQL/Translator/Parser/Sybase.pm b/lib/SQL/Translator/Parser/Sybase.pm index d5df085..acda87e 100644 --- a/lib/SQL/Translator/Parser/Sybase.pm +++ b/lib/SQL/Translator/Parser/Sybase.pm @@ -1,7 +1,7 @@ package SQL::Translator::Parser::Sybase; # ------------------------------------------------------------------- -# $Id: Sybase.pm,v 1.9 2004-02-09 22:23:40 kycl4rk Exp $ +# $Id: Sybase.pm,v 1.10 2005-06-28 16:39:41 mwz444 Exp $ # ------------------------------------------------------------------- # Copyright (C) 2002-4 SQLFairy Authors # @@ -40,7 +40,7 @@ DBI-Sybase parser included with SQL::Translator. use strict; use vars qw[ $DEBUG $VERSION $GRAMMAR @EXPORT_OK ]; -$VERSION = sprintf "%d.%02d", q$Revision: 1.9 $ =~ /(\d+)\.(\d+)/; +$VERSION = sprintf "%d.%02d", q$Revision: 1.10 $ =~ /(\d+)\.(\d+)/; $DEBUG = 0 unless defined $DEBUG; use Data::Dumper; @@ -398,8 +398,8 @@ sub parse { reference_table => $cdata->{'reference_table'}, reference_fields => $cdata->{'reference_fields'}, match_type => $cdata->{'match_type'} || '', - on_delete => $cdata->{'on_delete_do'}, - on_update => $cdata->{'on_update_do'}, + on_delete => $cdata->{'on_delete'} || $cdata->{'on_delete_do'}, + on_update => $cdata->{'on_update'} || $cdata->{'on_update_do'}, ) or die $table->error; } } diff --git a/lib/SQL/Translator/Parser/XML/SQLFairy.pm b/lib/SQL/Translator/Parser/XML/SQLFairy.pm index 86cec9b..67a9bfc 100644 --- a/lib/SQL/Translator/Parser/XML/SQLFairy.pm +++ b/lib/SQL/Translator/Parser/XML/SQLFairy.pm @@ -1,7 +1,7 @@ package SQL::Translator::Parser::XML::SQLFairy; # ------------------------------------------------------------------- -# $Id: SQLFairy.pm,v 1.13 2004-12-21 01:29:23 grommit Exp $ +# $Id: SQLFairy.pm,v 1.14 2005-06-28 16:39:41 mwz444 Exp $ # ------------------------------------------------------------------- # Copyright (C) 2003 Mark Addison , # @@ -100,7 +100,7 @@ To convert your old format files simply pass them through the translator :) use strict; use vars qw[ $DEBUG $VERSION @EXPORT_OK ]; -$VERSION = sprintf "%d.%02d", q$Revision: 1.13 $ =~ /(\d+)\.(\d+)/; +$VERSION = sprintf "%d.%02d", q$Revision: 1.14 $ =~ /(\d+)\.(\d+)/; $DEBUG = 0 unless defined $DEBUG; use Data::Dumper; @@ -186,7 +186,7 @@ sub parse { foreach (@nodes) { my %data = get_tagfields($xp, $_, "sqlf:", qw/name type table fields reference_fields reference_table - match_type on_delete_do on_update_do extra/ + match_type on_delete on_update extra/ ); $table->add_constraint( %data ) or die $table->error; } diff --git a/t/23xml-xmi-parser-rational.t b/t/23xml-xmi-parser-rational.t index 688b97a..b7aa8fc 100644 --- a/t/23xml-xmi-parser-rational.t +++ b/t/23xml-xmi-parser-rational.t @@ -97,13 +97,13 @@ sub constraint_ok { " match_type is '$test->{match_type}'" ) if exists $test->{match_type}; - is( $con->on_delete_do, $test->{on_delete_do}, - " on_delete_do is '$test->{on_delete_do}'" ) - if exists $test->{on_delete_do}; + is( $con->on_delete, $test->{on_delete}, + " on_delete is '$test->{on_delete}'" ) + if exists $test->{on_delete}; - is( $con->on_update_do, $test->{on_update_do}, - " on_update_do is '$test->{on_update_do}'" ) - if exists $test->{on_update_do}; + is( $con->on_update, $test->{on_update}, + " on_update is '$test->{on_update}'" ) + if exists $test->{on_update}; } sub test_table {