From: Ken Youens-Clark Date: Sun, 25 Jan 2004 18:13:46 +0000 (+0000) Subject: Wasn't producing constraint defs, fixed indices to be a list. X-Git-Tag: v0.06~231 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b3d280e2bd997ca22ff07caa875f39e3fdabf565;p=dbsrgits%2FSQL-Translator.git Wasn't producing constraint defs, fixed indices to be a list. --- diff --git a/lib/SQL/Translator/Producer/YAML.pm b/lib/SQL/Translator/Producer/YAML.pm index 74fbece..101c00b 100644 --- a/lib/SQL/Translator/Producer/YAML.pm +++ b/lib/SQL/Translator/Producer/YAML.pm @@ -1,7 +1,7 @@ package SQL::Translator::Producer::YAML; # ------------------------------------------------------------------- -# $Id: YAML.pm,v 1.6 2003-10-17 19:48:38 dlc Exp $ +# $Id: YAML.pm,v 1.7 2004-01-25 18:13:46 kycl4rk Exp $ # ------------------------------------------------------------------- # Copyright (C) 2003 darren chamberlain , # Ken Y. Clark . @@ -42,7 +42,7 @@ takes a long time. use strict; use vars qw($VERSION); -$VERSION = sprintf "%d.%02d", q$Revision: 1.6 $ =~ /(\d+)\.(\d+)/; +$VERSION = sprintf "%d.%02d", q$Revision: 1.7 $ =~ /(\d+)\.(\d+)/; use YAML qw(Dump); @@ -78,15 +78,17 @@ sub view_table { my $table = shift; return { - 'name' => $table->name, - 'order' => $table->order, - 'options' => $table->options || [], - 'comments' => $table->comments || '', - 'indices' => { - map { ($_->name => view_index($_)) } - $table->get_indices - }, - 'fields' => { + 'name' => $table->name, + 'order' => $table->order, + 'options' => $table->options || [], + 'comments' => $table->comments || '', + 'constraints' => [ + map { view_constraint($_) } $table->get_constraints + ], + 'indices' => [ + map { view_index($_) } $table->get_indices + ], + 'fields' => { map { ($_->name => view_field($_)) } $table->get_fields }, @@ -94,6 +96,25 @@ sub view_table { } # ------------------------------------------------------------------- +sub view_constraint { + my $constraint = shift; + + return { + 'deferrable' => scalar $constraint->deferrable, + 'expression' => scalar $constraint->expression, + 'fields' => scalar $constraint->fields, + 'match_type' => scalar $constraint->match_type, + 'name' => scalar $constraint->name, + 'options' => scalar $constraint->options, + 'on_delete' => scalar $constraint->on_delete, + 'on_update' => scalar $constraint->on_update, + 'reference_fields' => scalar $constraint->reference_fields, + 'reference_table' => scalar $constraint->reference_table, + 'type' => scalar $constraint->type, + }; +} + +# ------------------------------------------------------------------- sub view_field { my $field = shift;