From: Chris Hilton Date: Wed, 24 May 2006 18:09:27 +0000 (+0000) Subject: Added tests to catch Oracle problem with parser being reused X-Git-Tag: v0.11008~438 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=32d8b258a2904e099d68272a386546333c3f7152;p=dbsrgits%2FSQL-Translator.git Added tests to catch Oracle problem with parser being reused --- diff --git a/t/30sqlt-diff.t b/t/30sqlt-diff.t index aadab62..ae78dc9 100644 --- a/t/30sqlt-diff.t +++ b/t/30sqlt-diff.t @@ -25,9 +25,10 @@ my $create2 = (-d "t") : catfile($Bin, "t", @create2); BEGIN { - maybe_plan(14, + maybe_plan(16, 'SQL::Translator::Parser::SQLite', 'SQL::Translator::Parser::MySQL', + 'SQL::Translator::Parser::Oracle', ); } @@ -43,7 +44,7 @@ like($out, qr/ALTER TABLE person ADD is_rock_star/, @cmd = ($sqlt_diff, "$create1=SQLite", "$create1=SQLite"); $out = `@cmd`; -like($out, qr/There were no differences/, "Properly detected no differences"); +like($out, qr/No differences found/, "Properly detected no differences"); my @mysql_create1 = qw(data mysql create.sql); my @mysql_create2 = qw(data mysql create2.sql); @@ -77,4 +78,23 @@ like($out, qr/ALTER TABLE employee ADD CONSTRAINT/, @cmd = ($sqlt_diff, "$mysql_create1=MySQL", "$mysql_create1=MySQL"); $out = `@cmd`; -like($out, qr/There were no differences/, "Properly detected no differences"); +like($out, qr/No differences found/, "Properly detected no differences"); + +my @oracle_create1 = qw(data oracle create.sql); +my @oracle_create2 = qw(data oracle create2.sql); + +my $oracle_create1 = (-d "t") + ? catfile($Bin, @oracle_create1) + : catfile($Bin, "t", @oracle_create1); + +my $oracle_create2 = (-d "t") + ? catfile($Bin, @oracle_create2) + : catfile($Bin, "t", @oracle_create2); + +@cmd = ($sqlt_diff, "$oracle_create1=Oracle", "$oracle_create2=Oracle"); +$out = `@cmd`; + +like($out, qr/ALTER TABLE TABLE1 DROP FOREIGN KEY/, + "Detected drop foreign key"); +like($out, qr/ALTER TABLE TABLE1 ADD CONSTRAINT/, + "Detected add constraint"); diff --git a/t/data/oracle/create.sql b/t/data/oracle/create.sql new file mode 100644 index 0000000..a57da64 --- /dev/null +++ b/t/data/oracle/create.sql @@ -0,0 +1,8 @@ + CREATE TABLE USER1.TABLE1 + ( FIELD_ID NUMBER(19,0) NOT NULL ENABLE, + OTHERFIELD NUMBER(19,0) NOT NULL ENABLE, + CONSTRAINT FK20072D375BA3E34A FOREIGN KEY (OTHERFIELD) + REFERENCES USER1.TABLE2 (ID) ON DELETE CASCADE ENABLE, + CONSTRAINT FK_FIELD_ID FOREIGN KEY (FIELD_ID) + REFERENCES USER1.TABLE3 (ID) ON DELETE CASCADE ENABLE + ) ; diff --git a/t/data/oracle/create2.sql b/t/data/oracle/create2.sql new file mode 100644 index 0000000..93dd6a8 --- /dev/null +++ b/t/data/oracle/create2.sql @@ -0,0 +1,8 @@ + CREATE TABLE USER1.TABLE1 + ( FIELD_ID NUMBER(19,0) NOT NULL ENABLE, + OTHERFIELD NUMBER(19,0) NOT NULL ENABLE, + CONSTRAINT FK_OTHERFIELD FOREIGN KEY (OTHERFIELD) + REFERENCES USER1.TABLE2 (ID) ON DELETE CASCADE ENABLE, + CONSTRAINT FK_FIELD_ID FOREIGN KEY (FIELD_ID) + REFERENCES USER1.TABLE3 (ID) ON DELETE CASCADE ENABLE + ) ;