X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FSQL%2FTranslator%2FParser%2FYAML.pm;h=462ddcde8c760fb3e57887eb6cdb7241ae7501c3;hb=0c04c5a2210135419771878dc7e341a1cba52cca;hp=2464fac793136fbffe989626e8215a71759a0773;hpb=4d4385499fa84e31f78abe4cacf517e4a11c7b8f;p=dbsrgits%2FSQL-Translator.git diff --git a/lib/SQL/Translator/Parser/YAML.pm b/lib/SQL/Translator/Parser/YAML.pm index 2464fac..462ddcd 100644 --- a/lib/SQL/Translator/Parser/YAML.pm +++ b/lib/SQL/Translator/Parser/YAML.pm @@ -1,28 +1,8 @@ package SQL::Translator::Parser::YAML; -# ------------------------------------------------------------------- -# $Id: YAML.pm,v 1.8 2006-03-10 14:55:19 grommit Exp $ -# ------------------------------------------------------------------- -# Copyright (C) 2002-4 SQLFairy Authors -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; version 2. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -# 02111-1307 USA -# ------------------------------------------------------------------- - use strict; -use vars qw($VERSION); -$VERSION = sprintf "%d.%02d", q$Revision: 1.8 $ =~ /(\d+)\.(\d+)/; +use warnings; +our $VERSION = '1.59'; use SQL::Translator::Schema; use SQL::Translator::Utils qw(header_comment); @@ -41,7 +21,7 @@ sub parse { # # Tables # - my @tables = + my @tables = map { $data->{'tables'}{ $_->[1] } } sort { $a->[0] <=> $b->[0] } map { [ $data->{'tables'}{ $_ }{'order'} || 0, $_ ] } @@ -49,14 +29,14 @@ sub parse { ; for my $tdata ( @tables ) { - + my $table = $schema->add_table( map { $tdata->{$_} ? ($_ => $tdata->{$_}) : () } (qw/name extra options/) ) or die $schema->error; - my @fields = + my @fields = map { $tdata->{'fields'}{ $_->[1] } } sort { $a->[0] <=> $b->[0] } map { [ $tdata->{'fields'}{ $_ }{'order'}, $_ ] } @@ -65,7 +45,7 @@ sub parse { for my $fdata ( @fields ) { $table->add_field( %$fdata ) or die $table->error; - $table->primary_key( $fdata->{'name'} ) + $table->primary_key( $fdata->{'name'} ) if $fdata->{'is_primary_key'}; } @@ -81,7 +61,7 @@ sub parse { # # Views # - my @views = + my @views = map { $data->{'views'}{ $_->[1] } } sort { $a->[0] <=> $b->[0] } map { [ $data->{'views'}{ $_ }{'order'}, $_ ] } @@ -95,7 +75,7 @@ sub parse { # # Triggers # - my @triggers = + my @triggers = map { $data->{'triggers'}{ $_->[1] } } sort { $a->[0] <=> $b->[0] } map { [ $data->{'triggers'}{ $_ }{'order'}, $_ ] } @@ -109,7 +89,7 @@ sub parse { # # Procedures # - my @procedures = + my @procedures = map { $data->{'procedures'}{ $_->[1] } } sort { $a->[0] <=> $b->[0] } map { [ $data->{'procedures'}{ $_ }{'order'}, $_ ] }