From: Arthur Axel 'fREW' Schmidt Date: Fri, 31 Jan 2014 14:24:48 +0000 (-0600) Subject: Correctly strip lines that are all whitespace X-Git-Tag: v0.002210~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=55e13b19b1b782ab29e1e6c381b6c1eb1ea9103c;p=dbsrgits%2FDBIx-Class-DeploymentHandler.git Correctly strip lines that are all whitespace --- diff --git a/Changes b/Changes index f4438f7..176c48e 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,7 @@ Revision history for {{$dist->name}} {{$NEXT}} + - Correctly strip lines that are all whitespace (fixes RT#92582) - Ditch RT 0.002209 2013-12-27 18:08:31 America/Chicago diff --git a/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm b/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm index e59c062..9e2a759 100644 --- a/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm +++ b/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm @@ -264,19 +264,20 @@ sub _split_sql_chunk { s/^(?:BEGIN|BEGIN TRANSACTION|COMMIT).*//mgi; # trim whitespaces - s/^\s+|\s+$//mg; + s/^\s+//gm; + s/\s+$//gm; # remove comments s/^--.*//gm; # remove blank lines - s/^\n//mg; + s/^\n//gm; # put on single line s/\n/ /g; } - return @sql; + return grep $_, @sql; } sub _run_sql { diff --git a/t/10-split-sql-chunk.t b/t/10-split-sql-chunk.t index 025e9fc..794e794 100644 --- a/t/10-split-sql-chunk.t +++ b/t/10-split-sql-chunk.t @@ -1,7 +1,7 @@ use strict; use warnings; -use Test::More tests => 1; +use Test::More; use DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator; @@ -15,3 +15,6 @@ BEGIN END; END +is_deeply [ split_sql_chunk( 'foo', ' ', 'bar' ) ], [qw( foo bar)]; + +done_testing;