From: Ken Youens-Clark Date: Fri, 6 Jun 2003 22:35:16 +0000 (+0000) Subject: Changed constant to a hash to avoid silly Perl errors about it being X-Git-Tag: v0.02~75 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=695c2da21bb24de6469a3494af95eebcc7007d6e;p=dbsrgits%2FSQL-Translator.git Changed constant to a hash to avoid silly Perl errors about it being redefined; other minor changes. --- diff --git a/lib/SQL/Translator/Schema/Constraint.pm b/lib/SQL/Translator/Schema/Constraint.pm index 148ca19..df1fdae 100644 --- a/lib/SQL/Translator/Schema/Constraint.pm +++ b/lib/SQL/Translator/Schema/Constraint.pm @@ -1,7 +1,7 @@ package SQL::Translator::Schema::Constraint; # ---------------------------------------------------------------------- -# $Id: Constraint.pm,v 1.4 2003-06-06 00:08:14 kycl4rk Exp $ +# $Id: Constraint.pm,v 1.5 2003-06-06 22:35:16 kycl4rk Exp $ # ---------------------------------------------------------------------- # Copyright (C) 2003 Ken Y. Clark # @@ -53,12 +53,13 @@ use vars qw($VERSION $TABLE_COUNT $VIEW_COUNT); $VERSION = 1.00; -use constant VALID_TYPE => { +my %VALID_CONSTRAINT_TYPE = ( PRIMARY_KEY, 1, UNIQUE, 1, CHECK_C, 1, FOREIGN_KEY, 1, -}; + NOT_NULL, 1, +); # ---------------------------------------------------------------------- sub init { @@ -91,7 +92,7 @@ Object constructor. for my $arg ( @fields ) { next unless $config->{ $arg }; - $self->$arg( $config->{ $arg } ) or return; + defined $self->$arg( $config->{ $arg } ) or return; } return $self; @@ -286,7 +287,8 @@ Get or set the constraint's name. =cut my $self = shift; - $self->{'name'} = shift if @_; + my $arg = shift || ''; + $self->{'name'} = $arg if $arg; return $self->{'name'} || ''; } @@ -480,7 +482,7 @@ Get or set the constraint's type. if ( my $type = uc shift ) { $type =~ s/_/ /g; return $self->error("Invalid constraint type: $type") - unless VALID_TYPE->{ $type }; + unless $VALID_CONSTRAINT_TYPE{ $type }; $self->{'type'} = $type; }