X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FSQL%2FTranslator%2FDiff.pm;h=dae513adf56859e0c3e2d67e7dfd4aaae7f7f80b;hb=e6642bff4ab915e171db8a00b5207e69d85a9d9a;hp=743c1053e72fb73a8c360dab4319ef6709389d13;hpb=24d9fe69f45176a383f9faf545211caa180ae118;p=dbsrgits%2FSQL-Translator.git diff --git a/lib/SQL/Translator/Diff.pm b/lib/SQL/Translator/Diff.pm index 743c105..dae513a 100644 --- a/lib/SQL/Translator/Diff.pm +++ b/lib/SQL/Translator/Diff.pm @@ -13,7 +13,7 @@ use base 'Class::Accessor::Fast'; # Input/option accessors __PACKAGE__->mk_accessors(qw/ ignore_index_names ignore_constraint_names ignore_view_sql - ignore_proc_sql output_db source_schema source_db target_schema target_db + ignore_proc_sql output_db source_schema target_schema case_insensitive no_batch_alters ignore_missing_methods producer_options /); @@ -45,15 +45,14 @@ sub schema_diff { ## _db is the name of the producer/db it came out of/into ## results are formatted to the source preferences - my ($source_schema, $source_db, $target_schema, $target_db, $options) = @_; + my ($source_schema, $source_db, $target_schema, $output_db, $options) = @_; $options ||= {}; my $obj = SQL::Translator::Diff->new( { %$options, source_schema => $source_schema, - source_db => $source_db, target_schema => $target_schema, - target_db => $target_db + output_db => $output_db } ); $obj->compute_differences->produce_diff_sql; @@ -229,6 +228,7 @@ sub produce_diff_sql { # TODO: sort out options %{ $self->producer_options } ); + $translator->producer_args->{no_transaction} = 1; my $schema = $translator->schema; $schema->add_table($_) for @tables; @@ -255,10 +255,11 @@ sub produce_diff_sql { } if ( @diffs ) { - if ( $self->target_db !~ /^(?:MySQL|SQLite)$/ ) { - unshift(@diffs, "-- Target database @{[$self->target_db]} is untested/unsupported!!!"); + if ( $self->output_db !~ /^(?:MySQL|SQLite|PostgreSQL)$/ ) { + unshift(@diffs, "-- Output database @{[$self->output_db]} is untested/unsupported!!!"); } - return join '', map { $_ ? "$_;\n\n" : "\n" } ("-- Convert schema '$src_name' to '$tar_name':", @diffs); + return join '', map { $_ ? ( $_ =~ /;$/xms ? $_ : "$_;\n\n" ) : "\n" } + ("-- Convert schema '$src_name' to '$tar_name':", @diffs); } return undef;