From: Justin Hunter Date: Sat, 22 Aug 2009 21:41:58 +0000 (-0700) Subject: add table attribute when creating new objects X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a69b5060fef1fc6dd183757290b5d4b4f5ccfc9c;p=dbsrgits%2FSQL-Translator-2.0-ish.git add table attribute when creating new objects --- diff --git a/lib/SQL/Translator/Parser/DDL/YAML.pm b/lib/SQL/Translator/Parser/DDL/YAML.pm index cb60564..7a39fc0 100644 --- a/lib/SQL/Translator/Parser/DDL/YAML.pm +++ b/lib/SQL/Translator/Parser/DDL/YAML.pm @@ -12,7 +12,7 @@ role SQL::Translator::Parser::DDL::YAML { use YAML qw(Load); use MooseX::MultiMethods; - multi method parse(Schema $data) { return $data } + multi method parse(Schema $data) { $data } multi method parse(Str $data) { $data = Load($data); @@ -40,6 +40,7 @@ role SQL::Translator::Parser::DDL::YAML { for my $fdata ( @fields ) { $fdata->{sql_data_type} = $self->data_type_mapping->{$fdata->{data_type}} || -99999; + $fdata->{table} = $table; my $column = Column->new($fdata); $table->add_column($column); @@ -47,11 +48,13 @@ role SQL::Translator::Parser::DDL::YAML { } for my $idata ( @{ $tdata->{'indices'} || [] } ) { + $idata->{table} = $table; my $index = Index->new($idata); $table->add_index($index); } for my $cdata ( @{ $tdata->{'constraints'} || [] } ) { + $cdata->{table} = $table; my $constraint = Constraint->new($cdata); $table->add_constraint($constraint); }