Subject: | SQL::Translator::Producer::PostgreSQL produce() in list context should return a list of statements |
Hi,
thanks for the great module.
I have found a little bug, confirmed in IRC.
SQL::Translator::Producer::PostgreSQL::produce() should return the
statements in a list not in one string, just like
SQL::Translator::Producer::MySQL.
Attached is a diff to the current svn. All tests are passing.
regards,
tina
Subject: | PostgreSQL.pm.diff |
Index: lib/SQL/Translator/Producer/PostgreSQL.pm
===================================================================
--- lib/SQL/Translator/Producer/PostgreSQL.pm (revision 1473)
+++ lib/SQL/Translator/Producer/PostgreSQL.pm (working copy)
@@ -190,8 +190,8 @@
my $qf = '';
$qf = '"' if ($translator->quote_field_names);
- my $output;
- $output .= header_comment unless ($no_comments);
+ my @output;
+ push @output, header_comment unless ($no_comments);
my (@table_defs, @fks);
for my $table ( $schema->get_tables ) {
@@ -216,10 +216,10 @@
});
}
- $output = join(";\n\n", @table_defs) . ";\n\n";
+ push @output, map { "$_;\n\n" } @table_defs;
if ( @fks ) {
- $output .= "--\n-- Foreign Key Definitions\n--\n\n" unless $no_comments;
- $output .= join( ";\n\n", @fks ) . ";\n";
+ push @output, "--\n-- Foreign Key Definitions\n--\n\n" unless $no_comments;
+ push @output, map { "$_;\n\n" } @fks;
}
if ( $WARN ) {
@@ -235,7 +235,9 @@
}
}
- return $output;
+ return wantarray
+ ? @output
+ : join ('', @output);
}
# -------------------------------------------------------------------