From: Justin Hunter Date: Tue, 1 Dec 2009 22:46:54 +0000 (-0800) Subject: fix for storing comments using Moose::Autobox and ->flatten X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=96d4d86119b13c9bf4a2158e7081d96f78bca86b;p=dbsrgits%2FSQL-Translator-2.0-ish.git fix for storing comments using Moose::Autobox and ->flatten --- diff --git a/lib/SQL/Translator/Parser/DDL/PostgreSQL.pm b/lib/SQL/Translator/Parser/DDL/PostgreSQL.pm index 233a4d2..f0f7afa 100644 --- a/lib/SQL/Translator/Parser/DDL/PostgreSQL.pm +++ b/lib/SQL/Translator/Parser/DDL/PostgreSQL.pm @@ -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'} }; diff --git a/lib/SQL/Translator/Parser/DDL/SQLite.pm b/lib/SQL/Translator/Parser/DDL/SQLite.pm index 786813a..b052dd8 100644 --- a/lib/SQL/Translator/Parser/DDL/SQLite.pm +++ b/lib/SQL/Translator/Parser/DDL/SQLite.pm @@ -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);