From: Ken Youens-Clark Date: Tue, 12 Aug 2003 22:03:59 +0000 (+0000) Subject: Added logic to ensure the PK fields are not nullable (thanks to S. Quinney). X-Git-Tag: v0.04~341 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=42c8fad45bfdcc415d8199e3032157a8f72d6f8a;p=dbsrgits%2FSQL-Translator.git Added logic to ensure the PK fields are not nullable (thanks to S. Quinney). --- diff --git a/lib/SQL/Translator/Schema/Field.pm b/lib/SQL/Translator/Schema/Field.pm index b558381..c2b4fa6 100644 --- a/lib/SQL/Translator/Schema/Field.pm +++ b/lib/SQL/Translator/Schema/Field.pm @@ -1,7 +1,7 @@ package SQL::Translator::Schema::Field; # ---------------------------------------------------------------------- -# $Id: Field.pm,v 1.11 2003-06-27 16:47:40 kycl4rk Exp $ +# $Id: Field.pm,v 1.12 2003-08-12 22:03:59 kycl4rk Exp $ # ---------------------------------------------------------------------- # Copyright (C) 2003 Ken Y. Clark # @@ -50,7 +50,7 @@ use SQL::Translator::Utils 'parse_list_arg'; use base 'Class::Base'; use vars qw($VERSION $TABLE_COUNT $VIEW_COUNT); -$VERSION = sprintf "%d.%02d", q$Revision: 1.11 $ =~ /(\d+)\.(\d+)/; +$VERSION = sprintf "%d.%02d", q$Revision: 1.12 $ =~ /(\d+)\.(\d+)/; # ---------------------------------------------------------------------- sub init { @@ -309,6 +309,14 @@ foreign keys; checks) are represented as table constraints. $self->{'is_nullable'} = $arg ? 1 : 0; } + if ( + defined $self->{'is_nullable'} && + $self->{'is_nullable'} == 1 && + $self->is_primary_key + ) { + $self->{'is_nullable'} = 0; + } + return defined $self->{'is_nullable'} ? $self->{'is_nullable'} : 1; }