From: Justin Hunter Date: Mon, 16 Nov 2009 19:54:40 +0000 (-0800) Subject: check and see if column exists before checking if it is a pkey X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0a7ce17ebd004c0f96d9f70370fe7a93820eed8f;p=dbsrgits%2FSQL-Translator-2.0-ish.git check and see if column exists before checking if it is a pkey --- diff --git a/lib/SQL/Translator/Object/Table.pm b/lib/SQL/Translator/Object/Table.pm index 79b8d8d..9040e96 100644 --- a/lib/SQL/Translator/Object/Table.pm +++ b/lib/SQL/Translator/Object/Table.pm @@ -124,7 +124,10 @@ class SQL::Translator::Object::Table extends SQL::Translator::Object is dirty { around add_sequence(Sequence $sequence does coerce) { $self->$orig($sequence->name, $sequence) } multi method primary_key { grep /^PRIMARY KEY$/, $_->type for $self->get_constraints } - multi method primary_key(Str $column) { $self->get_column($column)->is_primary_key(1) } + multi method primary_key(Str $column) { + die "Column $column does not exist!" unless $self->exists_column($column); + $self->get_column($column)->is_primary_key(1); + } method is_valid { return $self->get_columns ? 1 : undef } method order { }