From: Justin Hunter Date: Wed, 10 Feb 2010 23:31:07 +0000 (-0800) Subject: change "fields" into "columns" (backcompat), probably needs some error/type checking X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=46ad29bbbe70fe437d12262f7aed7f5ab252114a;p=dbsrgits%2FSQL-Translator-2.0-ish.git change "fields" into "columns" (backcompat), probably needs some error/type checking --- diff --git a/lib/SQL/Translator/Object/Table.pm b/lib/SQL/Translator/Object/Table.pm index ed27e27..13f83a7 100644 --- a/lib/SQL/Translator/Object/Table.pm +++ b/lib/SQL/Translator/Object/Table.pm @@ -3,6 +3,7 @@ class SQL::Translator::Object::Table extends SQL::Translator::Object is dirty { use MooseX::Types::Moose qw(Any Bool HashRef Str); use MooseX::MultiMethods; use SQL::Translator::Types qw(Column Constraint Index Schema Sequence); + use SQL::Translator::Object::Column; use SQL::Translator::Object::Constraint; clean; @@ -167,4 +168,15 @@ class SQL::Translator::Object::Table extends SQL::Translator::Object is dirty { die "Can't drop non-existant constraint " . $name unless $self->exists_constraint($name); $self->$orig($name); } + + around BUILDARGS(ClassName $self: @args) { + my $args = $self->$orig(@args); + + my $fields = delete $args->{fields}; + + tie %{$args->{columns}}, 'Tie::IxHash'; + $args->{columns}{$_} = SQL::Translator::Object::Column->new( name => $_ ) for @$fields; + + return $args; + } }