From: Chris Hilton Date: Mon, 30 Oct 2006 19:41:48 +0000 (+0000) Subject: Added comment to diff output if target database is not one of the few, the proud X-Git-Tag: v0.11008~399 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=bf459ae6d4bd87b47e8b03ddfdd10f3b422b67b1;p=dbsrgits%2FSQL-Translator.git Added comment to diff output if target database is not one of the few, the proud --- diff --git a/lib/SQL/Translator/Diff.pm b/lib/SQL/Translator/Diff.pm index 9b60803..3f421e8 100644 --- a/lib/SQL/Translator/Diff.pm +++ b/lib/SQL/Translator/Diff.pm @@ -310,6 +310,9 @@ END push(@diffs, @diffs_at_end); if ( @diffs ) { + if ( $target_db !~ /^(MySQL|SQLServer|Oracle)$/ ) { + unshift(@diffs, "-- Target database $target_db is untested/unsupported!!!"); + } return join( "\n", "-- Convert schema '$src_name' to '$tar_name':\n", @diffs, "\n" ); diff --git a/t/30sqlt-diff.t b/t/30sqlt-diff.t index ae78dc9..a9fdea6 100644 --- a/t/30sqlt-diff.t +++ b/t/30sqlt-diff.t @@ -25,7 +25,7 @@ my $create2 = (-d "t") : catfile($Bin, "t", @create2); BEGIN { - maybe_plan(16, + maybe_plan(19, 'SQL::Translator::Parser::SQLite', 'SQL::Translator::Parser::MySQL', 'SQL::Translator::Parser::Oracle', @@ -37,6 +37,7 @@ my @cmd = ($sqlt_diff, "$create1=SQLite", "$create2=SQLite"); my $out = `@cmd`; +like($out, qr/-- Target database SQLite is untested/, "Detected 'untested' comment"); like($out, qr/ALTER TABLE person CHANGE iq/, "Detected altered 'iq' field"); like($out, qr/ALTER TABLE person ADD is_rock_star/, "Detected missing rock star field"); @@ -60,6 +61,7 @@ my $mysql_create2 = (-d "t") @cmd = ($sqlt_diff, "$mysql_create1=MySQL", "$mysql_create2=MySQL"); $out = `@cmd`; +unlike($out, qr/-- Target database MySQL is untested/, "Did not detect 'untested' comment"); like($out, qr/ALTER TABLE person CHANGE person_id/, "Detected altered 'person_id' field"); like($out, qr/ALTER TABLE person CHANGE iq/, "Detected altered 'iq' field"); like($out, qr/ALTER TABLE person CHANGE name/, "Detected altered 'name' field"); @@ -94,6 +96,7 @@ my $oracle_create2 = (-d "t") @cmd = ($sqlt_diff, "$oracle_create1=Oracle", "$oracle_create2=Oracle"); $out = `@cmd`; +unlike($out, qr/-- Target database Oracle is untested/, "Did not detect 'untested' comment"); like($out, qr/ALTER TABLE TABLE1 DROP FOREIGN KEY/, "Detected drop foreign key"); like($out, qr/ALTER TABLE TABLE1 ADD CONSTRAINT/,