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 <kclark@cpan.org>
#
$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 {
for my $arg ( @fields ) {
next unless $config->{ $arg };
- $self->$arg( $config->{ $arg } ) or return;
+ defined $self->$arg( $config->{ $arg } ) or return;
}
return $self;
=cut
my $self = shift;
- $self->{'name'} = shift if @_;
+ my $arg = shift || '';
+ $self->{'name'} = $arg if $arg;
return $self->{'name'} || '';
}
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;
}