From: Matt S Trout Date: Tue, 17 Jan 2006 01:57:59 +0000 (+0000) Subject: Fix to add_columns with column info arguments X-Git-Tag: v0.05005~117^2~45 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=30126ac7b856d95f9234188363aca54a4d190610;p=dbsrgits%2FDBIx-Class.git Fix to add_columns with column info arguments --- diff --git a/lib/DBIx/Class/ResultSource.pm b/lib/DBIx/Class/ResultSource.pm index 8d0b0d8..04dfd8a 100644 --- a/lib/DBIx/Class/ResultSource.pm +++ b/lib/DBIx/Class/ResultSource.pm @@ -48,7 +48,7 @@ sub add_columns { my $columns = $self->_columns; while (my $col = shift @cols) { - my $column_info = ref $cols[0] ? shift : {}; + my $column_info = ref $cols[0] ? shift(@cols) : {}; # If next entry is { ... } use that for the column info, if not # use an empty hashref @@ -57,6 +57,7 @@ sub add_columns { $columns->{$col} = $column_info; } push @{ $self->_ordered_columns }, @added; + return $self; } *add_column = \&add_columns; @@ -143,7 +144,7 @@ sub set_primary_key { =head2 primary_columns Read-only accessor which returns the list of primary keys. - + =cut sub primary_columns { @@ -233,7 +234,7 @@ sub add_relationship { attrs => $attrs }; $self->_relationships(\%rels); - return 1; + return $self; # XXX disabled. doesn't work properly currently. skip in tests. diff --git a/lib/DBIx/Class/TableInstance.pm b/lib/DBIx/Class/TableInstance.pm index 32c6886..13b100a 100644 --- a/lib/DBIx/Class/TableInstance.pm +++ b/lib/DBIx/Class/TableInstance.pm @@ -26,7 +26,7 @@ DBIx::Class::TableInstance - provides a classdata table object and method proxie sub _mk_column_accessors { my ($class, @cols) = @_; - $class->mk_group_accessors('column' => @cols); + $class->mk_group_accessors('column' => grep { !ref } @cols); } =head2 add_columns diff --git a/t/lib/DBICTest/Schema/Artist.pm b/t/lib/DBICTest/Schema/Artist.pm index baf730a..47f22e8 100644 --- a/t/lib/DBICTest/Schema/Artist.pm +++ b/t/lib/DBICTest/Schema/Artist.pm @@ -3,7 +3,7 @@ package DBICTest::Schema::Artist; use base 'DBIx::Class::Core'; DBICTest::Schema::Artist->table('artist'); -DBICTest::Schema::Artist->add_columns(qw/artistid name/); +DBICTest::Schema::Artist->add_columns('artistid', {}, 'name'); DBICTest::Schema::Artist->set_primary_key('artistid'); __PACKAGE__->mk_classdata('field_name_for', {