From: Justin Hunter Date: Sat, 19 Sep 2009 16:47:32 +0000 (-0700) Subject: add is_valid check and make sure you can't add a table with the same name X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=079f0c7842454b95ad3a3ad63774d3db5fea9c0e;p=dbsrgits%2FSQL-Translator-2.0-ish.git add is_valid check and make sure you can't add a table with the same name --- diff --git a/lib/SQL/Translator/Object/Table.pm b/lib/SQL/Translator/Object/Table.pm index 54d28c1..bc5f9d0 100644 --- a/lib/SQL/Translator/Object/Table.pm +++ b/lib/SQL/Translator/Object/Table.pm @@ -114,5 +114,9 @@ class SQL::Translator::Object::Table extends SQL::Translator::Object is dirty { multi method primary_key(Any $) { grep /^PRIMARY KEY$/, $_->type for $self->get_constraints } multi method primary_key(Str $column) { $self->get_column($column)->is_primary_key(1) } + method is_valid { return $self->get_columns ? 1 : undef } method order { } + + before name($name?) { die "Can't use table name $name" if $name && $self->schema->exists_table($name); } + }