From: Johannes Plunien Date: Sun, 2 Nov 2008 01:19:09 +0000 (+0100) Subject: split sql statements for deploy only if SQLT::Producer returned a scalar X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=407d67f7c7aa44616bc1f50da1dadcfbc5d81a8d;p=dbsrgits%2FDBIx-Class-Historic.git split sql statements for deploy only if SQLT::Producer returned a scalar --- diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index c6ca8f2..6ca5a7d 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -1753,8 +1753,10 @@ sub deployment_statements { sub deploy { my ($self, $schema, $type, $sqltargs, $dir) = @_; - foreach my $statement ( $self->deployment_statements($schema, $type, undef, $dir, { no_comments => 1, %{ $sqltargs || {} } } ) ) { - foreach my $line ( split(";\n", $statement)) { + my @statements = $self->deployment_statements($schema, $type, undef, $dir, { no_comments => 1, %{ $sqltargs || {} } } ); + foreach my $statement ( @statements ) { + my $deploy = sub { + my $line = shift; next if($line =~ /^--/); next if(!$line); # next if($line =~ /^DROP/m); @@ -1769,6 +1771,14 @@ sub deploy { warn qq{$@ (running "${line}")}; } $self->_query_end($line); + }; + if (@statements > 1) { + $deploy->( $statement ); + } + else { + foreach my $line ( split(";\n", $statement)) { + $deploy->( $line ); + } } } }