From: Justin Hunter Date: Sun, 23 Aug 2009 07:02:25 +0000 (-0700) Subject: fix the way columns are added to triggers/constraints/indexes X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5fdf332978b3c05239819b059f243726185e434b;p=dbsrgits%2FSQL-Translator-2.0-ish.git fix the way columns are added to triggers/constraints/indexes --- diff --git a/lib/SQL/Translator/Parser/DDL/YAML.pm b/lib/SQL/Translator/Parser/DDL/YAML.pm index 7a39fc0..a02143e 100644 --- a/lib/SQL/Translator/Parser/DDL/YAML.pm +++ b/lib/SQL/Translator/Parser/DDL/YAML.pm @@ -47,15 +47,21 @@ role SQL::Translator::Parser::DDL::YAML { $table->primary_key($column->name) if $fdata->{is_primary_key}; } - for my $idata ( @{ $tdata->{'indices'} || [] } ) { + for my $idata ( @{ $tdata->{'indices'} || [] } ) { $idata->{table} = $table; + my $columns = delete $idata->{fields}; + my $index = Index->new($idata); + $index->add_column($table->get_column($_)) for @$columns; $table->add_index($index); } for my $cdata ( @{ $tdata->{'constraints'} || [] } ) { $cdata->{table} = $table; + $cdata->{reference_columns} = delete $cdata->{reference_fields}; + my $columns = delete $cdata->{fields} || []; my $constraint = Constraint->new($cdata); + $constraint->add_column($table->get_column($_)) for @$columns; $table->add_constraint($constraint); } } @@ -82,9 +88,9 @@ role SQL::Translator::Parser::DDL::YAML { keys %{ $data->{'triggers'} }; for my $tdata ( @triggers ) { - my @columns = delete $tdata->{fields} || (); + my $columns = delete $tdata->{fields} || (); my $trigger = Trigger->new($tdata); - $trigger->add_column($schema->get_table($tdata->{on_table})->get_column($_)) for @columns; + $trigger->add_column($schema->get_table($tdata->{on_table})->get_column($_)) for @$columns; $schema->add_trigger($trigger); }