From: Justin Hunter Date: Tue, 25 Aug 2009 05:51:28 +0000 (-0700) Subject: parse mysql ddl procedures & views X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=84f95c6efc7b1f1fed900e1e0c7be98906372273;p=dbsrgits%2FSQL-Translator-2.0-ish.git parse mysql ddl procedures & views --- diff --git a/lib/SQL/Translator/Parser/DDL/MySQL.pm b/lib/SQL/Translator/Parser/DDL/MySQL.pm index a1045e5..502a4d7 100644 --- a/lib/SQL/Translator/Parser/DDL/MySQL.pm +++ b/lib/SQL/Translator/Parser/DDL/MySQL.pm @@ -151,25 +151,22 @@ role SQL::Translator::Parser::DDL::MySQL { normalize_field($_) for $table->get_fields; } -# my @procedures = sort { $result->{procedures}->{ $a }->{'order'} <=> $result->{procedures}->{ $b }->{'order'} } keys %{ $result->{procedures} }; - -# for my $proc_name ( @procedures ) { -# $schema->add_procedure( -# name => $proc_name, -# owner => $result->{procedures}->{$proc_name}->{owner}, -# sql => $result->{procedures}->{$proc_name}->{sql}, -# ); -# } - -# my @views = sort { $result->{views}->{ $a }->{'order'} <=> $result->{views}->{ $b }->{'order'} } keys %{ $result->{views} }; + for my $proc_name ( keys %{ $result->{procedures} } ) { + my $procedure = Procedure->new({ name => $proc_name, + owner => $result->{procedures}->{$proc_name}->{owner}, + sql => $result->{procedures}->{$proc_name}->{sql} + }); + $schema->add_procedure($procedure); + } -# for my $view_name ( keys %{ $result->{'views'} } ) { -# $schema->add_view( -# name => $view_name, -# sql => $result->{'views'}->{$view_name}->{sql}, -# ); -# } - return $schema; + for my $view_name ( keys %{ $result->{'views'} } ) { + my $view = View->new({ + name => $view_name, + sql => $result->{'views'}->{$view_name}->{sql}, + }); + $schema->add_view($view); + } + return 1; } # Takes a field, and returns