fix for storing comments using Moose::Autobox and ->flatten
Justin Hunter [Tue, 1 Dec 2009 22:46:54 +0000 (14:46 -0800)]
lib/SQL/Translator/Parser/DDL/PostgreSQL.pm
lib/SQL/Translator/Parser/DDL/SQLite.pm

index 233a4d2..f0f7afa 100644 (file)
@@ -2,6 +2,7 @@ use MooseX::Declare;
 role SQL::Translator::Parser::DDL::PostgreSQL {
     use MooseX::Types::Moose qw(Str);
     use MooseX::MultiMethods;
+    use Moose::Autobox;
     use SQL::Translator::Constants qw(:sqlt_types :sqlt_constants);
     use SQL::Translator::Types qw(Schema);
     use aliased 'SQL::Translator::Object::Column';
@@ -37,7 +38,7 @@ role SQL::Translator::Parser::DDL::PostgreSQL {
             $schema->add_table($table);
     
             $table->extra({ temporary => 1 }) if $tdata->{'temporary'};
-            $table->comments( $tdata->{'comments'} );
+            $table->comments( $tdata->{'comments'}->flatten ) if $tdata->{comments};
     
             my @fields = sort { $tdata->{'fields'}{ $a }{'order'} <=> $tdata->{'fields'}{ $b }{'order'} } keys %{ $tdata->{'fields'} };
     
index 786813a..b052dd8 100644 (file)
@@ -2,6 +2,7 @@ use MooseX::Declare;
 role SQL::Translator::Parser::DDL::SQLite {
     use MooseX::Types::Moose qw(Str);
     use MooseX::MultiMethods;
+    use Moose::Autobox;
     use SQL::Translator::Constants qw(:sqlt_types :sqlt_constants);
     use SQL::Translator::Types qw(Schema);
     use aliased 'SQL::Translator::Object::Column';
@@ -44,7 +45,7 @@ role SQL::Translator::Parser::DDL::SQLite {
         for my $table_name ( @tables ) {
             my $tdata =  $result->{'tables'}{ $table_name };
             my $table = Table->new({ name  => $tdata->{'name'}, schema => $schema });
-            $table->comments( $tdata->{'comments'} );
+            $table->comments( $tdata->{'comments'}->flatten ) if $tdata->{comments};
             $schema->add_table($table);
     
             for my $fdata ( @{ $tdata->{'fields'} } ) {
@@ -56,7 +57,6 @@ role SQL::Translator::Parser::DDL::SQLite {
                     default_value     => $fdata->{'default'},
                     is_auto_increment => $fdata->{'is_auto_inc'},
                     is_nullable       => $fdata->{'is_nullable'},
-                    comments          => $fdata->{'comments'},
                     table             => $table,
                 });
                 $table->add_column($field);