From: Arthur Axel 'fREW' Schmidt Date: Thu, 10 Mar 2011 04:01:51 +0000 (-0600) Subject: migrate drop_table to future X-Git-Tag: v0.11011~27^2~13 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=11bfa99116a9aaf0642064d06ebcdefdcd8e9de1;p=dbsrgits%2FSQL-Translator.git migrate drop_table to future --- diff --git a/lib/SQL/Translator/Generator/DDL/SQLServer.pm b/lib/SQL/Translator/Generator/DDL/SQLServer.pm index 18b399f..9482281 100644 --- a/lib/SQL/Translator/Generator/DDL/SQLServer.pm +++ b/lib/SQL/Translator/Generator/DDL/SQLServer.pm @@ -165,5 +165,13 @@ sub table { "\n);", } +sub drop_table { + my ($self, $table) = @_; + my $name = $table->name; + my $q_name = $self->quote($name); + "IF EXISTS (SELECT name FROM sysobjects WHERE name = '$name' AND type = 'U')" . + " DROP TABLE $q_name;\n" +} + 1; diff --git a/lib/SQL/Translator/Producer/SQLServer.pm b/lib/SQL/Translator/Producer/SQLServer.pm index fbe4125..e4373e2 100644 --- a/lib/SQL/Translator/Producer/SQLServer.pm +++ b/lib/SQL/Translator/Producer/SQLServer.pm @@ -38,9 +38,7 @@ sub produce { $output .= "\n"; $output .= "--\n-- Drop tables\n--\n\n" unless $no_comments; foreach my $table (@tables) { - my $name = $table->name; - my $q_name = unreserve($name); - $output .= "IF EXISTS (SELECT name FROM sysobjects WHERE name = '$name' AND type = 'U') DROP TABLE $q_name;\n" + $output .= $future->drop_table($table); } }