From: Arthur Axel 'fREW' Schmidt Date: Thu, 10 Mar 2011 04:14:01 +0000 (-0600) Subject: less accumulators more reduction X-Git-Tag: v0.11011~27^2~10 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9b76e208c86a027835d968e53d885427355da53a;p=dbsrgits%2FSQL-Translator.git less accumulators more reduction --- diff --git a/lib/SQL/Translator/Generator/DDL/SQLServer.pm b/lib/SQL/Translator/Generator/DDL/SQLServer.pm index 8425a0a..70782a2 100644 --- a/lib/SQL/Translator/Generator/DDL/SQLServer.pm +++ b/lib/SQL/Translator/Generator/DDL/SQLServer.pm @@ -170,7 +170,7 @@ sub drop_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" + " DROP TABLE $q_name;" } sub remove_table_constraints { @@ -178,7 +178,7 @@ sub remove_table_constraints { my $name = $table->name; my $q_name = $self->quote($name); "IF EXISTS (SELECT name FROM sysobjects WHERE name = '$name' AND type = 'U')" . - " ALTER TABLE $q_name NOCHECK CONSTRAINT all;\n" + " ALTER TABLE $q_name NOCHECK CONSTRAINT all;" } 1; diff --git a/lib/SQL/Translator/Producer/SQLServer.pm b/lib/SQL/Translator/Producer/SQLServer.pm index fe29c9b..f4b225c 100644 --- a/lib/SQL/Translator/Producer/SQLServer.pm +++ b/lib/SQL/Translator/Producer/SQLServer.pm @@ -26,14 +26,11 @@ sub produce { if ($add_drop_table) { my @tables = sort { $b->order <=> $a->order } $schema->get_tables; $output .= "--\n-- Turn off constraints\n--\n\n" unless $no_comments; - foreach my $table (@tables) { - $output .= $future->remove_table_constraints($table) - } + $output .= join "\n", map $future->remove_table_constraints($_), @tables; $output .= "\n"; $output .= "--\n-- Drop tables\n--\n\n" unless $no_comments; - foreach my $table (@tables) { - $output .= $future->drop_table($table); - } + $output .= join "\n", map $future->drop_table($_), @tables; + $output .= "\n"; } # these need to be added separately, as tables may not exist yet