From: Justin Hunter Date: Sun, 23 Aug 2009 07:02:57 +0000 (-0700) Subject: breakout Table creation X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4e0b0baf346179f4c5325083fe825e928db1dada;p=dbsrgits%2FSQL-Translator-2.0-ish.git breakout Table creation --- diff --git a/lib/SQL/Translator/Parser/DDL/YAML.pm b/lib/SQL/Translator/Parser/DDL/YAML.pm index a02143e..b1c0dc9 100644 --- a/lib/SQL/Translator/Parser/DDL/YAML.pm +++ b/lib/SQL/Translator/Parser/DDL/YAML.pm @@ -30,12 +30,14 @@ role SQL::Translator::Parser::DDL::YAML { keys %{ $data->{'tables'} }; for my $tdata ( @tables ) { - my $table = Table->new({ map { $tdata->{$_} ? ($_ => $tdata->{$_}) : () } qw/name extra options/ }); + my $table = Table->new({ name => $tdata->{name}, schema => $schema }); + $table->extra($tdata->{extra}) if $tdata->{extra}; + $table->options($tdata->{options}) if $tdata->{options}; $schema->add_table($table); - + my @fields = map { $tdata->{'fields'}{ $_->[1] } } - map { [ $tdata->{'fields'}{ $_ }{'order'}, $_ ] } + map { [ $tdata->{'fields'}{ $_ }{'order'} || 0, $_ ] } keys %{ $tdata->{'fields'} }; for my $fdata ( @fields ) {