From: Justin Hunter Date: Tue, 21 Jun 2011 18:30:53 +0000 (-0700) Subject: some better handling of munging fields to columns X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=82e209aa083cf5f796661c71a862ebeb2da67e64;p=dbsrgits%2FSQL-Translator-2.0-ish.git some better handling of munging fields to columns --- diff --git a/lib/SQL/Translator/Object/Table.pm b/lib/SQL/Translator/Object/Table.pm index dd9e17a..1389933 100644 --- a/lib/SQL/Translator/Object/Table.pm +++ b/lib/SQL/Translator/Object/Table.pm @@ -208,9 +208,11 @@ class SQL::Translator::Object::Table extends SQL::Translator::Object is dirty { around BUILDARGS(ClassName $self: @args) { my $args = $self->$orig(@args); - my $fields = delete $args->{fields}; - - $args->{columns}{$_} = SQL::Translator::Object::Column->new( name => $_ ) for @$fields; + my $fields = delete $args->{fields} || []; + $fields = ref($fields) eq 'ARRAY' ? $fields : [ $fields ]; + my $ix_hash = Tie::IxHash->new(); + $ix_hash->STORE($_, SQL::Translator::Object::Column->new( name => $_ )) for @$fields; + $args->{columns} = $ix_hash; return $args; }