From: Justin Hunter Date: Tue, 22 Sep 2009 00:35:02 +0000 (-0700) Subject: add some error checking to add_column and an alias to it X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=de1e817ea3b450c64b635e1b7b9604b2986dcb85;p=dbsrgits%2FSQL-Translator-2.0-ish.git add some error checking to add_column and an alias to it --- diff --git a/lib/SQL/Translator/Object/Table.pm b/lib/SQL/Translator/Object/Table.pm index 41d54c7..462dc85 100644 --- a/lib/SQL/Translator/Object/Table.pm +++ b/lib/SQL/Translator/Object/Table.pm @@ -91,7 +91,12 @@ class SQL::Translator::Object::Table extends SQL::Translator::Object is dirty { default => 0 ); - around add_column(Column $column) { $self->$orig($column->name, $column) } + method add_field(Column $column does coerce) { $self->add_column($column) } + + around add_column(Column $column does coerce) { + die "Can't use column name " . $column->name if $self->exists_column($column->name) || $column->name eq ''; + return $self->$orig($column->name, $column); + } around add_constraint(Constraint $constraint) { my $name = $constraint->name; if ($name eq '') {